Q:

Python program to convert Celsius to Fahrenheit

belongs to collection: Python Basic Programs

0

In this tutorial, we will learn how to write a python program for converting degree Celsius temperature into degree Fahrenheit temperature.

Celsius:

Celsius is a unit of measurement for temperature, and it is also known as centigrade, and it is SI derived unit used by most of the countries worldwide.

It is named after the Swedish astronomer Anders Celsius.

Fahrenheit:

Fahrenheit is also a temperature scale, and it is named after Polish-born German physicist Daniel Gabriel Fahrenheit, and it uses degrees Fahrenheit as a unit for temperature.

Suppose we have a temperature in degree Celsius, and our task is to convert the value of temperature into the degree Fahrenheit and display it.

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

Example:

Input: Temperature value in degree Celsius: 34   

Output: The 37.00 degree Celsius is equal to: 93.20-degree Fahrenheit  

 

Input: Temperature value in degree Celsius: 40  

Output: The 45.00 degree Celsius is equal to: 113.00-degree Fahrenheit  

 

Approach:

We can input the degree Celsius temperature and apply the conversation formula of degree Fahrenheit from degree Celsius and display it on screen. The following is the relationship of degree Celsius and degree Fahrenheit:

T(°Fahrenheit)=(T(°Celsius)*1.8)+32

OR we can write:

T(°Fahrenheit)=(T(°Celsius)*9/5)+32

Example:

celsius_1 = float(input("Temperature value in degree Celsius: " ))  
  
# For Converting the temperature to degree Fahrenheit by using the above  
# given formula  
Fahrenheit_1 = (celsius_1 * 1.8) + 32  
    
# print the result  
print('The %.2f degree Celsius is equal to: %.2f Fahrenheit'  
      %(celsius_1, Fahrenheit_1))  
  
print("----OR----")  
celsius_2 = float (input("Temperature value in degree Celsius: " ))  
Fahrenheit_2 = (celsius_2 * 9/5) + 32  
    
# print the result  
print ('The %.2f degree Celsius is equal to: %.2f Fahrenheit'  
      %(celsius_2, Fahrenheit_2))  

Output:

Temperature value in degree Celsius:  34
The 34.00 degree Celsius is equal to: 93.20 Fahrenheit
----OR----
Temperature value in degree Celsius:  23
The 23.00 degree Celsius is equal to: 73.40 Fahrenheit

To Convert Degree Fahrenheit into Degree Celsius:

The user can use the following formula for converting degree Fahrenheit into degree Celsius:

Example:

Fahrenheit_1 = float( input("Temperature value in degree Fahrenheit: " ))  
  
# For Converting the temperature from degree Fahrenheit to degree Celsius   
# by using the above given formula  
celsius_1 = (Fahrenheit_1 - 32)  / 1.8  
    
# Print the result  
print ('The %.2f degree Fahrenheit is equal to: %.2f Celsius'  
      %(Fahrenheit_1, celsius_1))  
  
print("----OR----")  
Fahrenheit_2 = float( input("Temperature value in degree Fahrenheit: " ))  
celsius_2 = (Fahrenheit_2 - 32) * 5/9  
    
# Print the result  
print ('The %.2f degree Fahrenheit is equal to: %.2f Celsius'  
      %(Fahrenheit_2, celsius_2))  

Output:

Temperature value in degree Fahrenheit:  113
The 113.00-degree Fahrenheit is equal to: 45.00 Celsius
----OR----
Temperature value in degree Fahrenheit:  234
The 234.00-degree Fahrenheit is equal to: 112.22 Celsius

Conclusion

In this tutorial, we discussed how to write a Python program for converting degree Fahrenheit to degree Celsius and vice versa.

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Python program to display calendar... >>
<< Python program to convert Kilometres to Miles...