Advertisement
Guest User

Untitled

a guest
May 25th, 2019
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. optionyes = ["yes", " yes", "yes ", " yes ", "y", " y", "y ", " y "]
  2. optiona = ["a", " a", "a ", " a "]
  3. optionb = ["b", " b", "b ", " b "]
  4. print("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
  5. while True:
  6. print("\nconvert:")
  7. print("\nA)Fahrenheit to Celsius \nB)Celsius to Fahrenheit\n\n")
  8. T = input("Enter option A or B: ")
  9. if T.lower() in optiona:
  10. try:
  11. Q = input("Enter a value in degrees Fahrenheit: ")
  12. C = round(((float(Q) - 32.0) * (5/9)), 2)
  13. print("\n" + str(Q) + " degrees Fahrenheit = " + str(C) + " degrees Celsius.\n")
  14. L = input("Make another calculation? \n(Y/N): ")
  15. if L.lower() in optionyes:
  16. continue
  17. else:
  18. print("Program terminated.\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
  19. break
  20. except:
  21. print("\n\nAn error occured.")
  22. elif T.lower() in optionb:
  23. try:
  24. W = input("Enter a value in degrees Celsius: ")
  25. V = round(((float(W) * (9/5)) + (32.0)), 2)
  26. print("\n" + str(W) + " degrees Celsius = " + str(V) + " degrees Fahrenheit.\n")
  27. M = input("Make another calculation? \n(Y/N): ")
  28. if M.lower() in optionyes:
  29. continue
  30. else:
  31. print("Program terminated.\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
  32. break
  33. except:
  34. print("An error occured.")
  35. elif T.lower() == "quit":
  36. print("\nProgram terminated.\n=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=")
  37. break
  38. elif T == "":
  39. print("\nYou must enter an option before continuing.\n")
  40. else:
  41. print("\nunrecognized input\n\n Try Again!\n")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement