Convert a temperature from Celsius to Fahrenheit with F = C * 9 / 5 + 32. Print it with exactly one digit after the decimal point.
What to build
A program that applies a formula, and shows the result with one decimal digit.
Requirements
- Read
Cas a whole number. - Use
F = C * 9 / 5 + 32. - Print
Fwith exactly one digit after the decimal point.
Input
One whole number C between -100 and 100.
Output
F with one decimal digit, for example 98.6.
Constraints
C is from -100 to 100.
Example
Input:
100
Output:
212.0
Why it works
/ gives a float, and the format code .1f always shows one decimal digit, even when that digit is 0.
Examples
Example 1 · Input
100
Expected output
212.0
Example 2 · Input
37
Expected output
98.6
Prompts inside input() are ignored when checking, so input("n: ") is fine.
Hints
Hint 1
f"{value:.1f}" writes a number with one decimal digit.
Solution
Show one correct solution (try it yourself first)
c = int(input())
f = c * 9 / 5 + 32
print(f"{f:.1f}")