Advertisement
Guest User

Untitled

a guest
Jun 24th, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.92 KB | None | 0 0
  1. import sys
  2.  
  3. while True:
  4. print("\nWhat would you like to convert? \nPress 1 for centimer/inch conversion, "
  5. "\n2 for meter/feet conversion, \n3 for kilogram/pound conversion."
  6. "\nAt any time, type 'end' to end the program.")
  7.  
  8. x = input("> ")
  9.  
  10. if x == "1":
  11. print("Press 1 for inches to centimers and 2 for centimers to inches.")
  12. y = input("> ")
  13. if y == "1":
  14. cm = 2.54
  15. inch = int(input("Enter a number of inches: "))
  16. print("\n%s inches is equal to %s centimeters" % (inch, inch*cm) + ".")
  17. if y == "2":
  18. inches = 0.3937
  19. centimeters = int(input("Enter a number of centimeters: "))
  20. print("\n%s centimeters is equal to %s inches" % (centimeters, centimeters*inches) + ".")
  21.  
  22.  
  23. if x == "2":
  24. print("Press 1 for feet to meters and 2 for meters to feet.")
  25. z = input("> ")
  26. if z == "1":
  27. m = 0.3048
  28. ft = int(input("Enter a number of feet: "))
  29. print("\n%s feet is equal to %s meters" % (ft, ft*m) + ".")
  30. if z == "2":
  31. feet = 3.2808
  32. meters = int(input("Enter a number of meters: "))
  33. print("\n%s meters is equal to %s feet" % (meters, meters*feet) + ".")
  34.  
  35.  
  36. if x == "3":
  37. print("Press 1 for pounds to kilograms and 2 for kilograms to pounds.")
  38. b = input("> ")
  39. if b == "1":
  40. kg = 0.4536
  41. lbs = int(input("Enter a number of pounds: "))
  42. print("\n%s pounds is equal to %s kilograms" % (lbs, lbs*kg) + ".")
  43. if b == "2":
  44. pounds = 2.205
  45. kilograms = int(input("Enter a number of kilograms: "))
  46. print("\n%s kilograms is equal to %s pounds" % (kilograms, pounds*kilograms) + ".")
  47.  
  48.  
  49. if x.lower() == "end":
  50. print("Goodbye!") + sys.exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement