Python program to convert Celsius to Fahrenheit

Python program to convert Celsius to Fahrenheit

Python program to convert celsius to fahrenheit

In this example, we will convert temperature in Celsius to Fahrenheit. To do this we will use the following formula

fah = ( cel * 1.8 ) + 32 

#python program to convert Celsius to Fahrenheit

cel=float(input(‘Enter temperature in degree Celsius: ‘))
fah=(cel * 1.8) + 32
print(‘{0} degrees Celsius is equal to {1} degrees Fahrenheit’.format(cel,fah))

Output

Enter temperature in degree Celsius: 50
50.0 degrees Celsius is equal to 122.0 degrees Fahrenheit

If we want to convert Fahrenheit to celsius so we have to use the given formula

cel = ( fah – 32 ) / 1.8 

fah=float(input(‘Enter temperature in degree Fahrenheit: ‘))
cel=(fah – 32) / 1.8
print(‘{0} degrees Fahrenheit is equal to {1} degrees Celsius’.format(fah,cel))

Output

Enter temperature in degrees Fahrenheit: 122
122.0 degrees Fahrenheit is equal to 50.0 degrees Celsius

If you like my post please share it with your friends by simply clicking the below social media button, and Don’t forget to comment so we will update ourselves.

Share in a Single Click

Leave a Reply

Your email address will not be published. Required fields are marked *