;

Python Program to Convert Celsius to Fahrenheit and Fahrenheit to Celsius


Tutorialsrack 22/04/2020 Python

In this Python program, we will learn how to convert Celsius to Fahrenheit and Fahrenheit to Celsius. 

For Converting Celsius to Fahrenheit, the formula is as:

celsius = (fahrenheit - 32) / 1.8

And for Converting Fahrenheit to Celsius, the formula is as: 

fahrenheit = (celsius * 1.8) + 32

Here is the source code of the program to convert Celsius to Fahrenheit and Fahrenheit to Celsius. 

Program 1: Convert Temperature from Celsius to Fahrenheit
# Python Program to convert temperature from celsius to fahrenheit

# change this value for a different result
celsius = 37.5

# calculate fahrenheit
fahrenheit = (celsius * 1.8) + 32
print('%0.1f degree Celsius is equal to %0.1f degree Fahrenheit' %(celsius,fahrenheit))
Output

37.5 degree Celsius is equal to 99.5 degree Fahrenheit

Convert Temperature from Fahrenheit to Celsius

Program 2: Convert Temperature from Fahrenheit to Celsius
# Program 2 - Python Program to convert temperature in Fahrenheit to Celsius

fahrenheit = 99.5

# calculate fahrenheit
celsius = (fahrenheit - 32) / 1.8
print('%0.1f degree Fahrenheit is equal to %0.1f degree Celsius' %(fahrenheit,celsius))
Output

99.5 degree Fahrenheit is equal to 37.5 degree Celsius


Related Posts



Comments

Recent Posts
Tags