Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- print ("Welcome")#welcomes you to the program
- again = 0 #sets to 0 to start the program
- while again == 0:#loops the program at the end of asking the conversion
- cont = 0
- while cont == 0:
- measurement = input("Do you want to convert length or mass? ")
- measurement = measurement.lower()
- if measurement == "length" or measurement == "mass":
- cont = 1
- cont = 0
- if measurement == "length":
- while cont == 0:
- length = input("Which unit do you want to convert? inch, foot, yard, or mile? ")
- length = length.lower()
- if length == "inch" or length == "foot" or length == "yard" or length == "mile":
- cont = 1
- cont = 0
- if measurement == "mass":
- while cont == 0:
- mass = input("Which unit do you want to convert? gram, ounce, pound, or ton? ")
- mass = mass.lower()
- if mass == "gram" or mass == "ounce" or mass == "pound" or mass == "ton":
- cont = 1
- #start inches convert
- cont = 0
- if length == "inch":
- while cont == 0:
- try:
- amount = float(input("How many inches do you want to convert? "))
- if amount >= 0:
- print (amount, "inches converts into...")
- cont = 1
- elif amount < 0:
- print ("Positive numbers only")
- except:
- print ("Numbers only")
- print ("\n")
- print (amount / 12, "feet")
- print (amount / 36, "yards")
- print (amount / 63360, "miles")
- print ("\n")
- cont = 0
- while cont == 0:
- again = input("Do you want to restart? Yes or No ")
- again = again.lower()
- if again == "yes":
- cont = 1
- again = 0
- if again == "no":
- cont = 1
- print ("Goodbye")
- print ("\n")
- #start foot convert
- cont = 0
- if length == "foot":
- while cont == 0:
- try:
- amount = float(input("How many feet do you want to convert? "))
- if amount >= 0:
- print (amount, "feet converts into...")
- cont = 1
- elif amount < 0:
- print ("Positive numbers only")
- except:
- print ("Numbers only")
- print ("\n")
- print (amount * 12, "inches")
- print (amount / 3, "yards")
- print (amount / 5280, "miles")
- print ("\n")
- cont = 0
- while cont == 0:
- again = input("Do you want to restart? Yes or No ")
- again = again.lower()
- if again == "yes":
- cont = 1
- again = 0
- if again == "no":
- cont = 1
- print ("Goodbye")
- print ("\n")
- #start yard convert
- cont = 0
- if length == "yard":
- while cont == 0:
- try:
- amount = float(input("How many yards do you want to convert? "))
- if amount >= 0:
- print (amount, "yards converts into...")
- cont = 1
- elif amount < 0:
- print ("Positive numbers only")
- except:
- print ("Numbers only")
- print ("\n")
- print (amount * 36, "inches")
- print (amount * 3, "feet")
- print (amount / 1760, "miles")
- print ("\n")
- cont = 0
- while cont == 0:
- again = input("Do you want to restart? Yes or No ")
- again = again.lower()
- if again == "yes":
- cont = 1
- again = 0
- if again == "no":
- cont = 1
- print ("Goodbye")
- print ("\n")
- #start mile convert
- cont = 0
- if length == "mile":
- while cont == 0:
- try:
- amount = float(input("How many miles do you want to convert? "))
- if amount >= 0:
- print (amount, "miles converts into...")
- cont = 1
- elif amount < 0:
- print ("Positive numbers only")
- except:
- print ("Numbers only")
- print ("\n")
- print (amount * 63360, "inches")
- print (amount * 5280, "feet")
- print (amount * 1760, "yards")
- print ("\n")
- cont = 0
- while cont == 0:
- again = input("Do you want to restart? Yes or No ")
- again = again.lower()
- if again == "yes":
- cont = 1
- again = 0
- if again == "no":
- cont = 1
- print ("Goodbye")
- print ("\n")
- #start grams convert
- cont = 0
- if mass == "gram":
- while cont == 0:
- try:
- amount = float(input("How many miles do you want to convert? "))
- if amount >= 0:
- print (amount, "miles converts into...")
- cont = 1
- elif amount < 0:
- print ("Positive numbers only")
- except:
- print ("Numbers only")
- print ("\n")
- print (amount * 63360, "inches")
- print (amount * 5280, "feet")
- print (amount * 1760, "yards")
- print ("\n")
- cont = 0
- while cont == 0:
- again = input("Do you want to restart? Yes or No ")
- again = again.lower()
- if again == "yes":
- cont = 1
- again = 0
- if again == "no":
- cont = 1
- print ("Goodbye")
- print ("\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement