Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- optionyes = ["yes", " yes", "yes ", " yes ", "y", " y", "y ", " y "]
- optiona = ["a", " a", "a ", " a "]
- optionb = ["b", " b", "b ", " b "]
- print("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
- while True:
- print("\nconvert:")
- print("\nA)Fahrenheit to Celsius \nB)Celsius to Fahrenheit\n\n")
- T = input("Enter option A or B: ")
- if T.lower() in optiona:
- try:
- Q = input("Enter a value in degrees Fahrenheit: ")
- C = round(((float(Q) - 32.0) * (5/9)), 2)
- print("\n" + str(Q) + " degrees Fahrenheit = " + str(C) + " degrees Celsius.\n")
- L = input("Make another calculation? \n(Y/N): ")
- if L.lower() in optionyes:
- continue
- else:
- print("Program terminated.\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
- break
- except:
- print("\n\nAn error occured.")
- elif T.lower() in optionb:
- try:
- W = input("Enter a value in degrees Celsius: ")
- V = round(((float(W) * (9/5)) + (32.0)), 2)
- print("\n" + str(W) + " degrees Celsius = " + str(V) + " degrees Fahrenheit.\n")
- M = input("Make another calculation? \n(Y/N): ")
- if M.lower() in optionyes:
- continue
- else:
- print("Program terminated.\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
- break
- except:
- print("An error occured.")
- elif T.lower() == "quit":
- print("\nProgram terminated.\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
- break
- elif T == "":
- print("\nYou must enter an option before continuing.\n")
- else:
- print("\nunrecognized input\n\n Try Again!\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement