ANPstore

BETA VERSI - KONVERSI SUHU @python

Nov 6th, 2023
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.67 KB | Software | 0 0
  1. import os
  2. import sys
  3. import time
  4.  
  5. #Digunakan untuk membersihkan hasil output yang telah divalidasi
  6. def set_close():
  7.     os.system('cls' if os.name == 'nt'else 'close')
  8. def set_aclose():
  9.     print('\n')
  10.     input('Error Input - Enter For Tryagain !')
  11.     set_close()
  12. def exit():
  13.     input('Thx For Use - Enter for exit')
  14.     set_close()
  15.     sys.exit()
  16. def exit00():
  17.     input('Enter for Back')
  18.     set_close()
  19.  
  20. #pilihan menu konversi
  21. def home():
  22.     print('\n')
  23.     print(' Konversi Suhu '.center(50,'—'))
  24.     print('|   CELCIUS  |  REAMUR  |  KELVIN  |  FARENHEIT  |')
  25.     print('—'*(50))
  26.     print('|celcius = C |reamur = R|Kelvin = K|Farenheit = F|'.center(50))
  27.     print(' 0. Exit --- 00. About '.center(50,'—'))
  28.     tanya = input('[C|R|K|F]~Input Menu :')
  29.     if tanya == 'c' or tanya == 'C':
  30.         tokyo_C()
  31.     elif tanya == 'R' or tanya == 'r':
  32.         tokyo_R()
  33.     elif tanya == 'K' or tanya == 'k':
  34.         tokyo_K()
  35.     elif tanya == 'F' or tanya == 'f':
  36.         tokyo_F()
  37.     elif tanya == '00' or tanya == 'about':
  38.         tokyo_about()
  39.     elif tanya == '0' or tanya == 'exit':
  40.         exit()
  41.     else:
  42.         set_aclose()
  43.         home()
  44.  
  45. #konversi suhu celcius
  46. def tokyo_C():
  47.     tanya_c = input('Next [N] . Back [B] : ')
  48.     if tanya_c == 'n' or tanya_c == 'N':
  49.         set_close()
  50.         tanya_c0 = float(input('Masukkan Suhu [°C]  :  '))
  51.         reamur = 4/5*tanya_c0
  52.         kelvin = tanya_c0+273
  53.         farenheit = 9/5*tanya_c0+32
  54.  
  55.         #Hasil konversi celcius
  56.         print(tanya_c0,'°C             : ','{:.1f}'.format(reamur),'°R')
  57.         print(tanya_c0,'°C             : ','{:.1f}'.format(kelvin),'°K')
  58.         print(tanya_c0,'°C             : ','{:.1f}'.format(farenheit),' °F')
  59.         return tokyo_C()
  60.  
  61.     elif tanya_c == 'b' or tanya_c == 'B':
  62.         set_close()
  63.         home()
  64.     else:
  65.         set_aclose()
  66.         tokyo_C()
  67.  
  68. #konversi suhu reamur
  69. def tokyo_R():
  70.     tanya_r = input('Next [N] . Back [B] : ')
  71.     if tanya_r == 'n' or tanya_r == 'N':
  72.         set_close()
  73.         tanya_r0 = float(input('Masukkan Suhu [°R]  :  '))
  74.         celcius = 5/4*tanya_r0
  75.         kelvin = (5/4*tanya_r0)+273
  76.         farenheit = (9/4*tanya_r0)+32
  77.  
  78.         #Hasil konversi celcius
  79.         print(tanya_r0,'°R             : ','{:.1f}'.format(celcius),'°C')
  80.         print(tanya_r0,'°R             : ','{:.1f}'.format(kelvin),'°K')
  81.         print(tanya_r0,'°R             : ','{:.1f}'.format(farenheit),' °F')
  82.         return tokyo_R()
  83.  
  84.     elif tanya_r == 'b' or tanya_r == 'B':
  85.         set_close()
  86.         home()
  87.     else:
  88.         set_aclose()
  89.         tokyo_R()
  90.  
  91. #Konversi Suhu Kelvin
  92. def tokyo_K():
  93.     tanya_K = input('Next [N] . Back [B] : ')
  94.     if tanya_K == 'n' or tanya_K == 'N':
  95.         set_close()
  96.         tanya_K0 = float(input('Masukkan Suhu [°K]  :  '))
  97.         reamur = 4/5*(tanya_K0-273)
  98.         celcius = ((tanya_K0-273.15)*9/5)+32
  99.         farenheit = 9/5*tanya_K0+32
  100.  
  101.         #Hasil konversi celcius
  102.         print(tanya_K0,'°K             : ','{:.1f}'.format(reamur),'°R')
  103.         print(tanya_K0,'°K             : ','{:.1f}'.format(celcius),'°K')
  104.         print(tanya_K0,'°K             : ','{:.1f}'.format(farenheit),' °F')
  105.         return tokyo_K()
  106.  
  107.     elif tanya_K == 'b' or tanya_K == 'B':
  108.         set_close()
  109.         home()
  110.     else:
  111.         set_aclose()
  112.         tokyo_K
  113.  
  114. #konversi suhu farenheit
  115. def tokyo_F():
  116.     tanya_f = input('Next [N] . Back [B] : ')
  117.     if tanya_f == 'n' or tanya_f == 'N':
  118.         set_close()
  119.         tanya_f0 = float(input('Masukkan Suhu [°F]  :  '))
  120.         reamur = 4/9*(tanya_f0-32)
  121.         kelvin = tanya_f0+273
  122.         celcius = (tanya_f0-32)*5/9+273
  123.  
  124.         #Hasil konversi celcius
  125.         print(tanya_f0,'°F             : ','{:.1f}'.format(reamur),'°R')
  126.         print(tanya_f0,'°F             : ','{:.1f}'.format(kelvin),'°K')
  127.         print(tanya_f0,'°F             : ','{:.1f}'.format(celcius),' °C')
  128.         return tokyo_F()
  129.  
  130.     elif tanya_f == 'b' or tanya_f == 'B':
  131.         set_close()
  132.         home()
  133.     else:
  134.         set_aclose()
  135.         tokyo_F()
  136.  
  137. #tentang/about pada kode
  138. def tokyo_about():
  139.     set_close()
  140.     print(' Version Beta-1.0.0 '.center(50))
  141.     print(' Author : Kelompok Tokyo 0'.center(50))
  142.     print('27 Oktober 2023,Sumatera Utara,Indonesia'.center(50))
  143.     print('-'*(50))
  144.     print('Alfan Nugraha Panjaitan @Ketua'.center(50))
  145.     print('Sri May Silpi @anggota'.center(50))
  146.     print('Marni Pane @anggota'.center(50))
  147.     print('Rifski Ardiansyah @anggota'.center(50))
  148.     print('Nurul Hidayani @anggota'.center(50))
  149.     print('-'*(50))
  150.     exit00()
  151.     home()
  152.    
  153. #memanggil fungsi home
  154. home()
Tags: #V1beta
Advertisement
Add Comment
Please, Sign In to add comment