-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemperatures.py
28 lines (27 loc) · 917 Bytes
/
temperatures.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
CP1404/CP5632 - Practical
Pseudocode for temperature conversion
"""
MENU = """C - Convert Celsius to Fahrenheit
F - Convert Fahrenheit to Celsius
Q - Quit"""
print(MENU)
choice = input(">>> ").upper()
while choice != "Q":
if choice == "C":
celsius = float(input("Celsius: "))
fahrenheit = celsius * 9.0 / 5 + 32
print("Result: {:.2f} F".format(fahrenheit))
elif choice == "F":
fahrenheit = float(input("Fahrenheit: "))
celsius = 5 / 9 * (fahrenheit - 32)
print("Result: {:.2f} C".format(celsius))
# TODO: Write this section to convert F to C and display the result
# Hint: celsius = 5 / 9 * (fahrenheit - 32)
# Remove the "pass" statement when you are done. It's a placeholder.
pass
else:
print("Invalid option")
print(MENU)
choice = input(">>> ").upper()
print("Thank you.")