# Convert Fahrenheit to Celsius in Python

Previously we have developed a Python program to convert the temperature from Celsius to Fahrenheit. In a similar way, we can also write a Python program to convert the temperature from Fahrenheit to Celsius.

The formula used to convert from Fahrenheit to Celsius is given as,
⁰C = (5/9) * (⁰F–32) or ⁰C = (⁰F–32) / 1.8

Mathematically,

Fahrenheit = 98
Celsius = (98-32) / 1.8 = 36.67
98 degree Fahrenheit is equivalent to 36.67 degree Celsius

## Python Program to Convert Fahrenheit to Celsius

This is the simplest and easiest way to convert Fahrenheit to Celsius. We will take a value of Fahrenheit when declaring the variables, the value of the Celsius will be calculated and stored in the variable, and finally, it will be displayed on the screen.

``````# Python program to convert Fahrenheit to Celsius

# take inputs
fahr = 74

# calculate Celsius
cel = (fahr-32) / 1.8

# display result
print('%0.1f degree Fahrenheit is equivalent to %0.1f
degree Celsius' %(fahr, cel))``````

Output:-

74.0 degree Fahrenheit is equivalent to 23.3 degree Celsius

In this program, we have hardcoded the value of Fahrenheit in the source code.

``fahr = 74``

Now, calculate the value of Celsius using formula.

``cel = (fahr-32) / 1.8``

Then, result will be displayed on the screen.

``print('%0.1f degree Fahrenheit is equivalent to %0.1f                             degree Celsius' %(fahr, cel))``

Write a python program to convert temperatures to and from Fahrenheit Celsius

In the previous program, input hardcoded in the program but in this program, input will be provided by the user.

``````# Python program to convert Fahrenheit to Celsius

# take inputs
fahr = float(input('Enter Fahrenheit value: '))

# calculate Celsius
cel = (fahr-32) / 1.8

# display result
print('%0.1f degree Fahrenheit is equivalent to %0.1f
degree Celsius' %(fahr, cel))``````

Output for different input values:-

Enter Fahrenheit value: 100
100.0 degree Fahrenheit is equivalent to 37.8 degree Celsius

Enter Fahrenheit value: 124.3
124.3 degree Fahrenheit is equivalent to 51.3 degree Celsius

Enter Fahrenheit value: -40
-40 degree Fahrenheit is equivalent to -40 degree Celsius

Note:- The -40⁰C is equal to the -40⁰F.

If you enjoyed this post, share it with your friends. Do you want to share more information about the topic discussed above or you find anything incorrect? Let us know in the comments. Thank you!

Python Programs