forked from lazyfay/Python-Project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkonvek_suhu.py
More file actions
77 lines (64 loc) · 1.53 KB
/
Copy pathkonvek_suhu.py
File metadata and controls
77 lines (64 loc) · 1.53 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
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
68
69
70
71
72
73
74
#Membuat program konversi suhu
#Input
suhu = float(input())
asal = input()
tujuan = input()
# Proses
hasil=None
# Konversi Celcius
if asal == "C" and tujuan == "F":
hasil = suhu * 1.8 + 32
elif asal == "C" and tujuan == "K":
hasil = suhu + 273.15
elif asal == "C" and tujuan == "Ra":
hasil = suhu * 1.8 + 32 + 459,67
elif asal == "C" and tujuan =="R":
hasil = suhu * 1.8 + 50
else:
()
# Konversi Kelvin
if asal == "K" and tujuan == "C":
hasil = suhu - 273.15
elif asal == "K" and tujuan == "F":
hasil = suhu * 1.8 - 459.67
elif asal == "K" and tujuan == "Ra":
hasil = suhu * 1.8
elif asal == "K" and tujuan =="R":
hasil = (suhu -273.15) * 1.8
else:
()
# Konversi Fahrenheit
if asal == "F" and tujuan == "C":
hasil = (suhu - 32) / 1.8
elif asal == "F" and tujuan == "K":
hasil = (suhu + 459.670) / 1.8
elif asal == "F" and tujuan == "Ra":
hasil = suhu + 459.67
elif asal == "F" and tujuan =="R":
hasil = (suhu - 32) / 2.25
else:
()
# Konversi Rankine
if asal == "Ra" and tujuan == "C":
hasil = (suhu - 32 - 459.67) / 1.8
elif asal == "Ra" and tujuan == "F":
hasil = suhu * 1.8 + 32
elif asal == "Ra" and tujuan == "K":
hasil = suhu / 1.8
elif asal == "Ra" and tujuan == "R":
hasil = (suhu - 32 - 459.67) / 2.25
else:
()
# Konversi Reanmur
if asal == "R" and tujuan == "C":
hasil = suhu * 1.25
elif asal == "R" and tujuan == "F":
hasil = suhu * 2.25 + 32
elif asal == "R" and tujuan == "K":
hasil = suhu * 1.25 + 273.15
elif asal == "R" and tujuan == "Ra":
hasil = suhu * 2.25 + 32 + 459.67
else:
()
# Output
print(hasil)