Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Python Temperature - pt.py

pt.py

Caricato da:
Scarica il programma completo

  1. #!/usr/bin/python
  2. #
  3. #by balloto
  4.  
  5. import os
  6.  
  7. def stampamenu():
  8.         print "********************************************"
  9.         print " BENVENUTO IN pythonTemperature 0.1 STABLE"
  10.         print "********************************************"
  11.         print ""
  12.         print "Modalita' del Programma:"
  13.         print ""
  14.         print "1) - Celsius => Kelvin"
  15.         print "2) - Kelvin => Celsius"
  16.         print "3) - Celsius => Fahrenheit"
  17.         print "4) - Fahrenheit => Celsius"
  18.         print "5) - Kelvin => Fahrenheit"
  19.         print "6) - Fahrenheit => Kelvin"
  20.         print "7) - Esci"
  21.         print ""
  22.         print "********************************************"
  23.  
  24. def continua():
  25.         enter = raw_input("Premi Invio per Continuare")
  26.         main()
  27.  
  28. def cel2kel():
  29.         cel = float(raw_input("Valore Celsius: "))
  30.         kel = float(cel+273)
  31.         print "Valore Kelvin: " + str(kel)
  32.         continua()
  33.  
  34. def kel2cel():
  35.         kel = float(raw_input("Valore Kelvin: "))
  36.         cel = float(kel-273)
  37.         print "Valore Celsius: " + str(cel)
  38.         continua()
  39.  
  40. def cel2far():
  41.         cel = float(raw_input("Valore Celsius: "))
  42.         far = float(((cel*9)/5)+32)
  43.         print "Valore Fahrenheit: " + str(far)
  44.         continua()
  45.  
  46. def far2cel():
  47.         far = float(raw_input("Valore Fahrenheit: "))
  48.         cel = float(((far-32)/9)*5)
  49.         print "Valore Celsius: " + str(cel)
  50.         continua()
  51.  
  52. def kel2far():
  53.         kel = float(raw_input("Valore Kelvin: "))
  54.         far = float((((kel-273)*9)/5)+32)
  55.         print "Valore Fahrenheit: " + str(far)
  56.         continua()
  57.  
  58. def far2kel():
  59.         far = float(raw_input("Valore Fahrenheit: "))
  60.         kel = float((((far-32)/9)*5)+273)
  61.         print "Valore Kelvin: " + str(kel)
  62.         continua()
  63.  
  64. def close():
  65.         print "Grazier per aver usato pT!"
  66.         os.system("sleep 2")
  67.         exit
  68.  
  69. def avvia(scelta):
  70.         if scelta == 1:
  71.                 cel2kel()
  72.         elif scelta == 2:
  73.                 kel2cel()
  74.         elif scelta == 3:
  75.                 cel2far()
  76.         elif scelta == 4:
  77.                 far2cel()
  78.         elif scelta == 5:
  79.                 kel2far()
  80.         elif scelta == 6:
  81.                 far2kel()
  82.         elif scelta == 7:
  83.                 close()
  84.         else:
  85.                 print "Opzione Inesistente!"
  86.                 os.system("sleep 1.43")
  87.                 main()
  88.  
  89. def main():
  90.         os.system("clear")
  91.         stampamenu()
  92.         print "\n"
  93.         scelta = int(raw_input("TUA SCELTA: "))
  94.         avvia(scelta)
  95.        
  96. main()