# Celsius to Fahrenheit in Python

Conversion from Celsius to Fahrenheit and from Fahrenheit to Celsius has an important role in the conversion of units system. Celsius is also known as centigrade. It is SI derived unit used by most of the countries worldwide. In this post, we will develop a Python program to convert Celsius to Fahrenheit.

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

Mathematically,

Celsius = 40
Fahrenheit = (40 * 1.8) + 32 = 104
40.0 degree Celsius is equivalent to 104.0 degree Fahrenheit

## Python Program to Convert Celsius to Fahrenheit

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

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

# take inputs
cel = 25

# calculate Fahrenheit
fahr = (cel * 1.8) + 32

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

Output:-

25.0 degree Celsius is equivalent to 77.0 degree Fahrenheit

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

``cel = 25``

Now, calculate the value of Fahrenheit using formula.

``fahr = (cel * 1.8) + 32``

Then, result will be displayed on the screen.

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

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

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

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

# take inputs
cel = float(input('Enter temprature in Celsius: '))

# calculate Fahrenheit
fahr = (cel * 1.8) + 32

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

Output for the different input values:-

Enter Celsius value: 20
20.0 degree Celsius is equivalent to 68.0 degree Fahrenheit

Enter Celsius value: 32.6
32.6 degree Celsius is equivalent to 90.7 degrees Fahrenheit

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