8000 Update solution · pbt001/python-basics-exercises@2ec585d · GitHub
[go: up one dir, main page]

Skip to content

Commit 2ec585d

Browse files
committed
Update solution
1 parent 34e2da9 commit 2ec585d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

ch06-functions-and-loops/3-challenge.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,25 @@ def convert_far_to_cel(temp_far):
1414
return temp_cel
1515

1616

17+
# Prompt the user to input a Fahrenheit temperature.
1718
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.
1823
temp_cel = convert_far_to_cel(float(temp_far))
24+
25+
# Display the converted temperature
1926
print(f"{temp_far} degrees F = {temp_cel:.2f} degrees C")
2027

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"")
2130

31+
# Prompt the user to input a Celsius temperature.
2232
temp_cel = input("\nEnter a temperature in degrees C: ")
33+
34+
# Convert the temperature to Fahrenheit.
2335
temp_far = convert_cel_to_far(float(temp_cel))
36+
37+
# Display the converted temperature
2438
print(f"{temp_cel} degrees C = {temp_far:.2f} degrees F")

0 commit comments

Comments
 (0)
0