-
Notifications
You must be signed in to change notification settings - Fork 0
/
FtoC.py
31 lines (31 loc) · 1.33 KB
/
FtoC.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
29
30
31
problem = True
while problem:
canausa = input("How do you want it converted? 1. F to C; 2. C to F\n")
if canausa.isdigit():
canausa = int(canausa)
if 0 < canausa < 2:
number = input("Temperature between 1 and 100 in Fahrenheit please: \n")
if number.isdigit() and -1 < int(number) < 101:
number = int(number)
food = (number-32)*.555555555556
food = "{:.3f}".format(food)
food = str(food)
print ("That is " + food + " C")
problem = False
else:
print("Your input needs to be a valid positive integer between 1 and 100.")
elif 1 < canausa < 3:
numberr = input("Temperature between 1 and 100 in Celsius please: \n")
if numberr.isdigit() and -1 < int(numberr) < 101:
numberr = int(numberr)
numberr = 1.8*numberr + 32
numberr = "{:.3f}".format(numberr)
numberr = str(numberr)
print ("That is " + numberr + " F")
problem = False
else:
print("Your input needs to be a valid positive integer between 1 and 100.")
else:
print("Your input needs to be 1 or 2. \n")
else:
print("Your input needs to be 1 or 2. \n")