Advertisement
rayslhcf

SpeedConvert

Aug 25th, 2014
233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.21 KB | None | 0 0
  1. def KmtoMil():
  2.     chi = int(input(" [1] KMH to MPH\n [2] MPH to KMH\n >> "))
  3.     if chi == 1:
  4.         inp = int(input("Enter kmh: "))
  5.         mph =  0.6214 * inp
  6.         print ("Speed: {0} MPH >> {1:.2f} Km/H".format(inp, mph))
  7.     elif chi == 2:
  8.         inp = int(input("Enter mph: "))
  9.         kmh =  inp / 0.6214
  10.         print ("Speed: {0} Km/H >> {1:.2f} MPH".format(inp, kmh))
  11.     else :
  12.         print("You must enter 1 or 2")
  13.  
  14. #-------------------------------------------------------------------------#
  15.  
  16. def CurrExc():
  17.         chi = int(input(" [1] THB to USD\n [2] USD to THB\n >> "))
  18.         if chi == 1:
  19.                 inp = int(input("Enter THB: "))
  20.                 usd =  inp/32.12
  21.                 print ("{0} THB equals {1:.2f} USD".format(inp, usd))
  22.         elif chi == 2:
  23.                 inp = int(input("Enter USD: "))
  24.                 thb =  inp * 32.12
  25.                 print ("{0} USD equals {1:.2f} THB".format(inp, thb))
  26.         else :
  27.                 print("You must enter 1 or 2")
  28.  
  29. #-------------------------------------------------------------------------#
  30. #  
  31. #              เรียกใช้ฟังก์ชั่นโดยการพิมพ์ KmToMil()
  32. #
  33. #-------------------------------------------------------------------------#
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement