Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- while True:
- print("\nWhat would you like to convert? \nPress 1 for centimer/inch conversion, "
- "\n2 for meter/feet conversion, \n3 for kilogram/pound conversion."
- "\nAt any time, type 'end' to end the program.")
- x = input("> ")
- if x == "1":
- print("Press 1 for inches to centimers and 2 for centimers to inches.")
- y = input("> ")
- if y == "1":
- cm = 2.54
- inch = int(input("Enter a number of inches: "))
- print("\n%s inches is equal to %s centimeters" % (inch, inch*cm) + ".")
- if y == "2":
- inches = 0.3937
- centimeters = int(input("Enter a number of centimeters: "))
- print("\n%s centimeters is equal to %s inches" % (centimeters, centimeters*inches) + ".")
- if x == "2":
- print("Press 1 for feet to meters and 2 for meters to feet.")
- z = input("> ")
- if z == "1":
- m = 0.3048
- ft = int(input("Enter a number of feet: "))
- print("\n%s feet is equal to %s meters" % (ft, ft*m) + ".")
- if z == "2":
- feet = 3.2808
- meters = int(input("Enter a number of meters: "))
- print("\n%s meters is equal to %s feet" % (meters, meters*feet) + ".")
- if x == "3":
- print("Press 1 for pounds to kilograms and 2 for kilograms to pounds.")
- b = input("> ")
- if b == "1":
- kg = 0.4536
- lbs = int(input("Enter a number of pounds: "))
- print("\n%s pounds is equal to %s kilograms" % (lbs, lbs*kg) + ".")
- if b == "2":
- pounds = 2.205
- kilograms = int(input("Enter a number of kilograms: "))
- print("\n%s kilograms is equal to %s pounds" % (kilograms, pounds*kilograms) + ".")
- if x.lower() == "end":
- print("Goodbye!") + sys.exit(0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement