Python Examples

Python Program to Convert Celsius To Fahrenheit

To understand the conversion of python Celsius to Fahrenheit and Fahrenheit to Celsius, we need to understand the two formulas given below. Let us learn Python Program to Convert Celsius To Fahrenheit.python program to convert celsius to fahrenheit

Source Code

Python Program to Convert Celsius to Fahrenheit

T(℉) = T(℃) x 9/5 + 32

Or, 

T(℉) = T(℃) x 1.8 + 32

To convert the value from python Celsius to Fahrenheit, we take the user’s Celsius temperature as input, convert it to Fahrenheit using the conversion formula, then display it. Look at the examples given below:

Input :

90

Output :

90.00 degrees Celsius is the same as 194 degrees Fahrenheit.

Input :

50

Output :

50.00 degrees Celsius is the same as 122 degrees Fahrenheit.

Input :

12

Output :

12 degrees Celsius is equal to 53.6 degrees Fahrenheit.

Source Code:

cls = float(input(‘Enter temperature in Celsius: ‘))  

  #calculate the Fahrenheit temperature

 fah = (cls * 1.8) + 32  

print(‘%0.1f Celsius is equal to %0.1f degrees Fahrenheit’%(cls,fah))  

Output

37.5 degrees Celsius is equal to 99.5 degrees Fahrenheit

What is the fastest way to convert Celsius to Fahrenheit?

To convert the temperatures from python Celsius to Fahrenheit and vice versa, understand these 2 formulas:

Formula to convert Celsius to Fahrenheit: 

(°C * 1.8) + 32 = °F

Formula to convert Fahrenheit to Celsius: 

(°F – 32) / 1.8 = °C

With the help of these 2 formulas, the user can easily make use of the program given above to 

How do you convert Fahrenheit to Celsius?

To convert this, we need to keep the Fahrenheit to Celsius formula in mind. 

C = (F-32)/1.8

C in the above formula is the temperature in Celsius and F is the temperature in Fahrenheit.

Fahrenheit to Celsius without Function

In Python, to convert temperature from Fahrenheit to Celsius, you must first ask the user to provide a temperature in Fahrenheit as the input, which will then be converted to Celsius by the compiler, look at the program given below:

Source Code:

                    

print("Enter Temperature in Fahrenheit: ")

fahren = float(input())

celi = (fahren-32)/1.8

print("\nEquivalent Temperature in Celsius: ", celi)

Output:

Enter Temperature in Fahrenheit:

98

Equivalent Temperature in Celsius

36.6666666666

Fahrenheit to Celsius using Function

As mentioned above, to convert the temperature of Fahrenheit to Celsius, the compiler takes the Fahrenheit values as the input and converts them to Celsius using the formula:

(°F – 32) / 1.8 = °C

Input :

90

Output :

90.00 degrees Fahrenheit is the same as 32.2222 degrees Celsius.

Input :

50

Output :

50.00 degrees Fahrenheit is the same as 1- degrees Celsius.

Input :

12

Output :

12 degrees Fahrenheit is the same as -11.1111 degrees Celsius.

FahToCel is a user-defined function that is used to convert Fahrenheit to Celsius temperatures. This function accepts a value as an argument and returns its Celsius equivalent.

Source Code:

                    

def FahToCel(fah):

    return (fah-32)/1.8



print("Enter Temperature in Fahrenheit: ", end="")

fahren = float(input())



celi = FahToCel(fahren)

print("\nEquivalent Temperature in Celsius = {:.2f}".format(cel))



Output:

Enter Temperature in Fahrenheit:

98

Equivalent Temperature in Celsius

36.6666666666

Share with friends

Customize your course in 30 seconds

Which class are you in?
5th
6th
7th
8th
9th
10th
11th
12th
Get ready for all-new Live Classes!
Now learn Live with India's best teachers. Join courses with the best schedule and enjoy fun and interactive classes.
tutor
tutor
Ashhar Firdausi
IIT Roorkee
Biology
tutor
tutor
Dr. Nazma Shaik
VTU
Chemistry
tutor
tutor
Gaurav Tiwari
APJAKTU
Physics
Get Started

Leave a Reply

avatar
  Subscribe  
Notify of

Customize your course in 30 seconds

Which class are you in?
No thanks.