I am learning Python and was trying out a code but it gave an error. i was expecting it to ask for an input of the degree of celsius i want to convert to fahrenheit, and then it would either tell me the converted value or (if the given value is <-273.15) it will print a sentence saying that it is not possible. But the code wouldn't run and it gave an error instead. The error probably has something to do with the colon but i am not sure.
Code:-
def con(Celsius):
Fahrenheit = (float(Celsius)*9)/5 + 32
return Fahrenheit
Celsius = float(input("Enter the temperature in Celsius: ")
if Celsius <= -273.15:
print("The temperature in Fahrenheit is "+ str(con(Celsius)))
else:
print("The lowest possible temperature that physical matter can reach is -273.15C")
Error:-
File ".\Celsius2Fahrenheit2.py", line 7
if Celsius <= -273.15:
^
SyntaxError: invalid syntax
I will be glad if someone can guide me through this and help me fix the error.
Aucun commentaire:
Enregistrer un commentaire