Advertisement
brilliant_moves

TempConversion.py

Nov 25th, 2014
344
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.63 KB | None | 0 0
  1. def convertToFK(t):
  2.     F = t * (9/5.0) + 32
  3.     K = t+273.15
  4.     print "Other Systems: %.2f F %.2f K" % (F,K)
  5.    
  6. def convertToCK(t):
  7.     C = (5/9.0) * (t-32)
  8.     K = C+273.15
  9.     print "Other Systems: %.2f C %.2f K" % (C,K)
  10.    
  11. def convertToCF(t):
  12.     C = t-273.15
  13.     F = C * (9/5.0) + 32
  14.     print "Other Systems: %.2f C %.2f F" % (C,F)
  15.  
  16. for i in range(3):
  17.     user_input = raw_input("Temp: ")
  18.     temp = int(user_input[:-2])
  19.     system = user_input[-1:]
  20.     if system=="C" or system=="c":
  21.         convertToFK(temp)
  22.     elif system=="F" or system=="f":
  23.         convertToCK(temp)
  24.     elif system=="K" or system=="k":
  25.         convertToCF(temp)
  26.     else:
  27.         print "Must be C, F or K"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement