Python Program to Convert Celsius To Fahrenheit and vice versa

In this example, we will write a simple program to convert units of measurement from celius to fahrenheit and vice versa in Python. The conversion formula plays an important role in writing the program. Let us see how the formula looks:-

Conversion Formula for Temperature conversion

C = (F – 32) * 5/9

F = (C * 9/5) + 32


To better understand this example, make sure you have knowledge of the following tutorials:-

Python Program to Convert Celsius To Fahrenheit:

celsius = float(input("Enter the temperature in celsius: "))
fahrenheit = (celsius * 9/5) + 32
print('%.2f celsius = %0.2f fahrenheit' %(celsius, fahrenheit))

The output of the above program is:-

Enter the temperature in celsius: 37
37.00 celsius = 98.60 fahrenheit

Python Program to Convert Fahrenheit to Celsius:

fahrenheit = float(input("Enter the temperature in fahrenheit: "))
celsius = (fahrenheit - 32) * 5/9
print('%.2f fahrenheit = %0.2f celsius' %(fahrenheit, celsius))

The output of the above program is:-

Enter the temperature in fahrenheit: 97
97.00 fahrenheit = 36.11 celsius
SHARE Python Program to Convert Celsius To Fahrenheit and vice versa

You may also like...


Warning: Undefined variable $category in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/sidebar_tutorial.php on line 10

Warning: Trying to access array offset on null in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/sidebar_tutorial.php on line 10

Warning: Attempt to read property "category_parent" on null in /www/wwwroot/followtutorials.com/wp-content/themes/hueman/sidebar_tutorial.php on line 10
Share