-
-
Notifications
You must be signed in to change notification settings - Fork 317
/
Copy pathConvert Temperature.py
67 lines (41 loc) · 1.37 KB
/
Convert Temperature.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
import math
def from_cel():
x = float(input("Enter Temperature: "))
y = input("You want to convert it into: \n (a)fahrenheit (b)Kelvin ")
if y == 'a':
final = (x*(9/5)) + 32
print(f"The temperature is: {final} °F")
else:
final = x + 273.15
print(f"The temperature is: {final} K")
def from_fah():
x = float(input("Enter Temperature: "))
y = input("You want to convert it into: \n (a)celsius (b)Kelvin ")
if y == 'a':
final = (x - 32)*(5/9)
print(f"The temperature is: {final} °C")
else:
final = (x - 32)*(5/9) + 273.15
print(f"The temperature is: {final} K")
def from_Kel():
x = float(input("Enter Temperature: "))
y = input("You want to convert it into: \n (a)celsius (b)fahrenheit ")
if y == 'a':
final = x - 273.15
print(f"The temperature is: {final} °C")
else:
final = (x - 273.15)*(5/9) + 32
print(f"The temperature is: {final} °F")
def get_temp():
global t
t = input("What would you like to convert from? (input no.): \n (1)Celsius (2)fahrenheit (3)Kelvin ")
get_temp()
if t == "1":
from_cel()
elif t == '2':
from_fah()
elif t == '3':
from_Kel()
else:
print("please enter a correct input")
get_temp()