-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathctof.py
More file actions
37 lines (34 loc) · 1.16 KB
/
ctof.py
File metadata and controls
37 lines (34 loc) · 1.16 KB
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
32
33
34
35
36
37
test_list_c = ['c','C']
test_list_f = ['f', 'F']
print('Do you want to convert in Celsius or Fahrenheit? Type C or type F')
t = input()
while True:
if t in test_list_c:
print('Type Fahrenheit value you want to convert to Celsius')
v = input()
while True:
if str.isdigit(v) == False:
print('Incorect format. Please type a number')
v = input()
else:
v = int(v)
break
celsius = (v - 32) * (5/9)
print('Temperature in Celsius is', celsius, ' C')
break
elif t in test_list_f:
print('Type Celsius value you want to convert to Fahrenheit')
v = input()
while True:
if str.isdigit(v) == False:
print('Incorect format. Please type a number')
v = input()
else:
v = int(v)
break
fahrenheit = (v * (9 / 5)) + 32
print('Temperature in Fahrenheit is', fahrenheit, ' F')
break
else:
print('Incorrect format. Please type C or F to choose your input temperature')
t = input()