File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -14,11 +14,25 @@ def convert_far_to_cel(temp_far):
14
14
return temp_cel
15
15
16
16
17
+ # Prompt the user to input a Fahrenheit temperature.
17
18
temp_far = input ("Enter a temperature in degrees F: " )
19
+
20
+ # Convert the temperature to Celsius.
21
+ # Note that `temp_far` must be converted to a `float`
22
+ # since `input()` returns a string.
18
23
temp_cel = convert_far_to_cel (float (temp_far ))
24
+
25
+ # Display the converted temperature
19
26
print (f"{ temp_far } degrees F = { temp_cel :.2f} degrees C" )
20
27
28
+ # You could also use `round()` instead of the formatting mini-language:
29
+ # print(f"{temp_far} degrees F = {round(temp_cel, 2)} degrees C"")
21
30
31
+ # Prompt the user to input a Celsius temperature.
22
32
temp_cel = input ("\n Enter a temperature in degrees C: " )
33
+
34
+ # Convert the temperature to Fahrenheit.
23
35
temp_far = convert_cel_to_far (float (temp_cel ))
36
+
37
+ # Display the converted temperature
24
38
print (f"{ temp_cel } degrees C = { temp_far :.2f} degrees F" )
You can’t perform that action at this time.
0 commit comments