-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemperature_conversion.py
More file actions
28 lines (17 loc) · 922 Bytes
/
Copy pathtemperature_conversion.py
File metadata and controls
28 lines (17 loc) · 922 Bytes
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
print("Enter a number, and I will convert it from Fahrenheit to celsius, or vice-versa.")
while True:
cel_or_far = (input("Enter 1 if you want from F-to-C or enter 2 if you want from C-to-F: "))
if cel_or_far.isdigit():
cel_or_far = int(cel_or_far)
if cel_or_far == 1:
far_cel = round(float(input("Enter the F number you want convert: ")))
output1 = round((far_cel - 32) * (5 / 9))
print(f"{far_cel}F is equal to {output1}C.")
elif cel_or_far == 2:
cel_far = round(float(input("Enter the C number you want convert: ")))
output2 = round(cel_far * (9 / 5) + 32)
print(f"{cel_far}C is equal to {output2}F.")
else:
print("You didn't enter 1 or 2. Try again.")
else:
print("Invalid input. Please enter a number.")