Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Aug 9th, 2012  |  syntax: Python  |  size: 0.55 KB  |  hits: 10  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. def main(convertArray, fromArray, toArray):
  2.   print("1 = miles to kilometers")
  3.   print("2 = gallons to litres")
  4.   print("3 = inches to centimeters")
  5.   x = (int(input("Conversion: ")))-1
  6.   toConvert = int(input("How many? "))
  7.   print("There are " + str(toConvert * convertArray[x]) + " " + toArray[x] + " in " + str(toConvert) + " " + fromArray[x])
  8.  
  9.  
  10. convertArray = [1.60934, 3.78541, 2.54]
  11. fromArray = ["miles", "gallons", "inches"]
  12. toArray = ["kilometers", "litres", "centimeters"]
  13. if __name__ == '__main__':
  14.     main(convertArray, fromArray, toArray)