Files
curriculum/1.solar-system/2.first-light/09.the-temperature/index.md

925 B

type, title, xp, duration, difficulty
type title xp duration difficulty
challenge The Temperature 75 30 2

The Temperature

[INCOMING — Mission Control, Earth]

Cadet, half the world reads temperature in Fahrenheit, the other half in Celsius. Build a converter.

Formula: C = (F - 32) * 5 / 9

Implement f_to_c(f) that returns a string of the form:

<F>°F = <C>°C

Where <C> is rounded to one decimal place using :.1f. Convert the input with float() first so the output is consistent for int and float inputs.

Examples:

  • f_to_c(32)"32.0°F = 0.0°C"
  • f_to_c(212)"212.0°F = 100.0°C"
  • f_to_c(98.6)"98.6°F = 37.0°C"

[END TRANSMISSION]

Your Task

In starter/starter.py, convert f to float, compute Celsius, return the formatted string.

Objectives

  • All three examples produce the exact expected string
  • Works for any numeric F input