Converting the temperature from Celsius to Fahrenheit in Python

Write a program in Python For Converting the temperature from Celsius to Fahrenheit.

Method 1

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

Output

Temperature value in degree Celsius: 33
The 33.00 degrees Celsius is equal to: 91.40 Fahrenheit
—-OR—-
Temperature value in degree Celsius: 22
The 22.00 degrees Celsius is equal to: 71.60 Fahrenheit

Method 2

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

Output

Temperature value in degree Fahrenheit: 88
The 88.00 degree Fahrenheit is equal to: 31.11 Celsius
—-OR—-
Temperature value in degree Fahrenheit: 55
The 55.00 degree Fahrenheit is equal to: 12.78 Celsius

Leave a Reply

Contents Copyrights Reserved By T4Tutorials