Learn about the Python program to convert Fahrenheit to Celsius in the below code example. Also, refer to the comments in the code snippet to get a detailed view about what’s actually happening.
Contents
Python program to convert Fahrenheit to Celsius
The below python code takes Fahrenheit value as an input and converts it into Celsius value. Refer the comments in the given code for better understanding.
Program:
# Python program to convert Fahrenheit to Celsius
# input
fahr = float(input('Enter Fahrenheit value: '))
# calculate Celsius
celsius = (fahr-32) / 1.8
# print result
print('%0.1f degree Fahrenheit is equivalent to %0.1f degree Celsius' %(fahr, celsius))
Output:
Enter Fahrenheit value: 36
36.0 degree Fahrenheit is equivalent to 2.2 degree Celsius
Hope above code works for you and Refer the below Related Codes to gain more insights. Happy coding and come back again.
Similar Code : Python program to convert Celsius to Fahrenheit