City Temperature Identification in Python


Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this temperature into Centigrade degrees.( F − 32 ) × 5 / 9

The program is a simple Python script that converts a temperature from Fahrenheit to Celsius. It prompts the user to input a temperature in Fahrenheit, converts it to Celsius using a mathematical formula, and then prints out the result.

The program first prompts the user to input a temperature in Fahrenheit using the input() function and assigns it to the variable "fr" by using the float() function to convert the input from a string to a floating point number.

Next, the program uses a mathematical formula to convert the temperature from Fahrenheit to Celsius. The formula to convert Fahrenheit to Celsius is: Celsius = (5/9) * (Fahrenheit - 32) . The program applies this formula by subtracting 32 from the input temperature "fr" and multiply it by 5/9 and assigns the value to a variable "cent"

Finally, the program uses the print() function to output the results, including the temperature in centigrade.


Source Code

"""
centigrade = 5/9 * (F-32)
"""
fr=float(input("Enter the Temperature:"))
cent=5.0/9.0*(fr-32)
print("Temparture in Centigrade=",cent)

Output

Enter the Temperature:34.45
Temparture in Centigrade= 1.3611111111111127


Example Programs