Write a Program to Convert Temperature From Fahrenheit to Celsius in Python

Given the temperature in Fahrenheit your task is to convert the  temperature in Fahrenheit to a Celsius. To convert the Fahrenheit to Celsius you have to use a formula.
 
 

Write a Program to Convert Temperature From Fahrenheit to Celsius in Python


 


The formula to convert Fahrenheit to Celsius is °C = [(°F-32)×5]/9

Where °C is Temperature in Celsius
°F  is temperature in Fahrenheit
32, 5, 9 are the constants  used to convert the temperature

Use the above formula into the Python program and convert the temperature to Celsius.




Write a Program to Convert Temperature From Fahrenheit to Celsius in Python

The Python program is of only three line code,  take a user input using input function call, use the above mathematical formula to get the Celsius and then  using the print function call in the temperature in Celsius let's get started.

Take a variable name fah,  ask a user to enter the temperature in Fahrenheit using input function call and then convert it into a float type.

fah = float(input("Enter Temperature in Fahrenheit : "))




Using the above formula into the program get the temperature in Celsius. Finally print the temperature in Fahrenheit and Celsius using the print function call.

celsius = ((fah - 32) * 5 ) / 9
print(f"Fahrenheit %.2f in Celsius is : %.2f" %(fah, celsius))




Python working code
========================

fah = float(input("Enter Temperature in Fahrenheit : "))
celsius = ((fah - 32) * 5 ) / 9
print(f"Fahrenheit %.2f in Celsius is : %.2f" %(fah, celsius))




Output
===================

Enter Temperature in Fahrenheit : 100
Fahrenheit 100.00 in Celsius is : 37.78
 


Output
=====================

Enter Temperature in Fahrenheit : 23
Fahrenheit 23.00 in Celsius is : -5.00



Output
================

Enter Temperature in Fahrenheit : 73
Fahrenheit 73.00 in Celsius is : 22.78



Conclusion
===============

Execute a program by providing the different Fahrenheit random temperatures and note down the results.

Comment down below if you have any suggestions or queries regarding the above program
 



Post a Comment

0 Comments