in this video, we will create a temperature convertor using if…elif..else that allows users to choose between F to C and C to F conversion.
print("#"*60)
print("##"+"Temperature Calculator".center(56)+"##")
print("#"*60+"\n")
print("""Would you like to convert from
F to C, or C to F?\n""")
print("Enter 1 for F to C")
print("Enter 2 for C to F")
strChoice = input("What do you choose?")
if (strChoice == "1"):
strF = input("Enter the temp in F: ")
flF = float(strF)
flC = (flF - 32) / 1.8
print(f"\nThe temp in C is {flC:.2f}.")
elif (strChoice == "2"):
flC = float(input("Enter the temp in C: "))
flF = flC * 1.8 + 32
print(f"\nThe temp in F is {flF:.2f}.")
else:
print("That is not a valid choice.")
print("\nThank you for trying my calculator.")