I am a total beginner in python and i am taking a course, my teacher has given an assignment where she told us to "Write a program that will ask the user if they want to enter fahrenheit (or f or F) or celsius (or c or C) - you must allow all variations shown here for this input. Then it will ask the user to enter the temperature (any number value, for this program you can assume the user follows directions and you do not need to verify it is a number). Based on the choice of fahrenheit or celsius, the program will convert the temperature to the other unit of measurement rounded to 2 decimal places." then we have to print a statement according to the temperature input by the user. This is how much i have done so far but it always prints as the first print statement no matter what the type input is. Any assistance would be appreciated. Thanks in advance!
type = str(input("Enter the temperature unit (fahrenheit or celsius):\n"))
temp = int(input("Enter the temperature:\n"))
a = "Celsius"
b = "celsius"
c = "C"
d = "c"
e = "Fahrenheit"
f = "fahrenheit"
g = "F"
h = "f"
if type != a or b or c or d or e or f or g or h:
print("You did not enter fahrenheit or celsius!")
else:
print("The temperature is", temp, "degrees.")
Aucun commentaire:
Enregistrer un commentaire