3 months ago
15 lines351 B
def fahrenheit(celsius): | |
"""Convert a temperature to Fahrenheit.""" | |
return celsius * 9 / 5 + 32 | |
| |
| |
def describe(celsius, unit="F"): | |
if unit == "F": | |
return f"{celsius} °C is {fahrenheit(celsius):.1f} °F" | |
return f"{celsius} °C" | |
| |
| |
for c in (0, 21, 37, 100): | |
print(describe(c)) | |
| |
# See the lesson README for what to try next. |