codescracker


python

Python Program to Convert Fahrenheit to Celsius



« Previous Program Next Program »


Convert Fahrenheit to Celsius in Python

To convert temperature from Fahrenheit to Celsius in python, you have to ask from user to enter temperature in Fahrenheit to convert that temperature into Celsius as shown in the program given below.

Let's suppose there is f temperature given in fahrenheit and you have to convert it into celsius then use the following conversion factor. Let's suppose c is the temperature in celsius:

c = (f-32)/1.8

Here c is temperature in celsius and f is given temperature in fahrenheit.

Python Programming Code to Convert Fahrenheit to Celsius

Following python program ask from user to enter the value of Fahrenheit to convert it into Celsius:

# Python Program - Convert Fahrenheit to Celsius

print("Enter 'x' for exit.");
fah = input("Enter Temperature in Fahrenheit: ");
if fah == 'x':
    exit();
else:
    fahrenheit = float(fah);
    celsius = (fahrenheit-32)/1.8;
    print("Temperature in Celsius =",celsius);

Here is the sample run of the above Python program demonstrating how to convert temperature from Fahrenheit to Celsius:

convert fahrenheit to celsius python

Now supply temperature in fahrenheit say 98.6 and press enter the get the same temperature in celsius:

fahrenheit to celsius python

Below is same program on python shell:

python convert fahrenheit to celsius

Program Video with Compile and Run

Same Program in Other Languages

You may also like to learn or practice the same program in other popular programming languages:


« Previous Program Next Program »








Tools
Calculator

Quick Links
Signup - Login - Give Online Test