fork(1) download
  1. '''Basic Converter by Michael Aminoff
  2. version 1.0
  3. Last edited 26.3.2013'''
  4.  
  5. print('Welcome to the program Basic Converter.')
  6. print()
  7. print('It can perform the following coversions:')
  8. print('Meters to Feet\nFeet to Meters\nKilos to Pounds\nPounds to Kilos')
  9. print('Kilometers to Miles\nMiles to Kilometers\nCelsius to Fahrenheit\nFahrenheit to Celsius')
  10. print()
  11.  
  12. def main():
  13. x = input('To which of the above units do you wish to convert? ')
  14. if x == 'Meters' or x == 'meters' or x == 'Meter' or x == 'meter':
  15. FTM()
  16.  
  17. if x == 'Feet' or x == 'feet' or x == 'Foot' or x == 'foot':
  18. MTF()
  19.  
  20. if x == 'Pounds' or x == 'pounds' or x == 'Pound' or x == 'pound':
  21. KTP()
  22.  
  23. if x == 'Kilos' or x == 'kilos' or x == 'Kilo' or x == 'kilo':
  24. PTK()
  25.  
  26. if x == 'Miles' or x == 'miles' or x == 'Mile' or x == 'mile':
  27. KTM()
  28.  
  29. if x == 'Kilometers' or x == 'kilometers' or x == 'Kilometer' or x == 'kilometer':
  30. MTK()
  31.  
  32. if x == 'Fahrenheit' or x == 'fahrenheit':
  33. CTF()
  34.  
  35. if x == 'Celsius' or x == 'celsius':
  36. FTC()
  37.  
  38. def FTM():
  39. a = float(input('Insert number of feet: '))
  40. b = float(0.304)
  41. print(a, 'feet is', b * a, 'meters')
  42.  
  43. def MTF():
  44. a = float(input('Insert number of meters: '))
  45. b = float(3.281)
  46. print(a, 'meters is', b * a, 'feet')
  47.  
  48. def KTP():
  49. a = float(input('Insert number of kilos: '))
  50. b = float(2.205)
  51. print(a, 'kilos is', b * a, 'pounds')
  52.  
  53. def PTK():
  54. a = float(input('Insert number of pounds: '))
  55. b = float(0.454)
  56. print(a, 'pounds is', b * a, 'kilos')
  57.  
  58. def KTM():
  59. a = float(input('Insert number of kilometers: '))
  60. b = float(0.621)
  61. print(a, 'kilometers is', b * a, 'miles')
  62.  
  63. def MTK():
  64. a = float(input('Insert number of miles: '))
  65. b = float(1.609)
  66. print(a, 'miles is', b * a, 'kilometers')
  67.  
  68. def CTF():
  69. a = float(input('Insert temperature in Celsius: '))
  70. b = float(a * 9/5 + 32)
  71. print(a, '°C is', b, '°F')
  72.  
  73. def FTC():
  74. a = float(input('Insert temperature in Fahrenheit: '))
  75. b = float((a - 32) * 5/9)
  76. print(a, '°F is', b, '°C')
  77.  
  78. def end():
  79. input('Press Enter to end program')
  80.  
  81. main()
  82. print()
  83. z = input('Do you wish to perform another conversion? yes/no ')
  84.  
  85. if z == 'yes':
  86. main()
  87.  
  88. if z == 'no':
  89. end()
  90.  
  91.  
Runtime error #stdin #stdout 0.08s 8832KB
stdin
Standard input is empty
stdout
Standard output is empty