Berikut merupakan Contoh Syntax Konferensi Suhu menggunakan bahasa pemrogaman PYTHON
def menu():
print("**
Program Konversi Suhu **")
print("Nama Ines Mahvida")
print("NIM
211011700064")
print("Kelas 02SIFM001")
print("[1]
Konversi Celcius")
print("[2]
Konversi Fahrenheit")
print("[3]
Konversi Reamur")
print("[4]
Konversi Kelvin")
print("[0]
Keluar")
menu()
option = int(input("Masukkan Menu: "))
while option != 0:
if option == 1:
#Konversi
Celcius
celcius =
float(input("Masukkan Nilai Celcius: "))
fahrenheit
= (9 / 5) * celcius + 32
reamur = (4
/ 5) * celcius
kelvin =
celcius + 273
#Print
Nilai Konversi Celcius
print("Nilai Celcius : ", celcius, "C")
print("Nilai
dalam fahrenheit :", fahrenheit, "F")
print("Nilai dalam reamur :", reamur, "R")
print("Nilai dalam Kelvin :", kelvin, "K")
print()
elif option ==
2:
#Konversi Fahrenheit
fahrenheit = float(input("Masukkan nilai Fahrenheit : "))
celcius
= (5 / 9) * (fahrenheit - 32)
reamur
= (4 / 9) * (fahrenheit - 32)
kelvin
= (5 / 9) * (fahrenheit - 32) + 273
#Print
Nilai Konversi Fahrenheit
print("Nilai Fahrenheit : ",
fahrenheit, "F")
print("Nilai dalam Celcius :", celcius, "C")
print("Nilai dalam reamur :", reamur, "R")
print("Nilai dalam Kelvin :", kelvin, "K")
print()
elif option ==
3:
#Konversi Reamur
reamur = float(input("Masukkan nilai Reamur : "))
celcius = (5 / 4) * reamur
fahrenheit = (9 / 4) * reamur + 32
kelvin = (5 / 4) * reamur + 273
#Print Nilai Konversi Reamur
print("Nilai reamur :", reamur, "R")
print("Nilai Celcius : ", celcius, "C")
print("Nilai dalam fahrenheit :", fahrenheit, "F")
print("Nilai dalam Kelvin :", kelvin, "K")
print()
elif option ==
4:
#Konversi Kelvin
kelvin = float(input("Masukkan nilai Kelvin : "))
celcius = kelvin - 273
fahrenheit = (9 / 5) * (kelvin - 273) + 32
reamur = (4 / 5) * (kelvin - 273)
#Print Nilai Kelvin
print("Nilai reamur :", reamur, "R")
print("Nilai Celcius : ", celcius, "C")
print("Nilai dalam fahrenheit :", fahrenheit, "F")
print("Nilai dalam Kelvin :", kelvin, "K")
print()
else:
print("Gaada Pilihannya!")
print()
menu()
option =
int(input("Masukkan Menu: "))
Tidak ada komentar:
Posting Komentar