Python program to convert Celsius to Fahrenheit
In this article, you will learn the Python program to convert units of measurement from Celsius to Fahrenheit and vice versa. Such type of program plays an important role in most scientific applications, as it is the most widely used temperature scale throughout the world. The Fahrenheit scale is mostly used in the United States.
In the Celsius scale, the boiling point of water is 100°C, and the freezing point is at 0°C, while in the Fahrenheit scale the boiling point of water is measured at 212°F and freezing point at 32°F.
Celsius to Fahrenheit
To convert temperatures in degrees Celsius to Fahrenheit, multiply by 1.8 (or 9/5) and add 32.
celsius * 1.8 = fahrenheit - 32
Here is a simple program to convert Celsius to Fahrenheit using Python.
# Python Program to convert temperature in celsius to fahrenheit
celsius = 42.5
# calculate fahrenheit
fahrenheit = (celsius * 1.8) + 32
print('%0.1f degree Celsius = %0.1f degree Fahrenheit' %(celsius,fahrenheit))
The above code returns the following output -
Fahrenheit to Celsius
Here is a simple program to convert Fahrenheit to Celsius using Python.
# Python Program to convert temperature in fahrenheit to celsius
fahrenheit = 128.5;
# calculate fahrenheit
celsius = (fahrenheit-32)/1.8;
print('%0.1f degree Fahrenheit = %0.1f degree Celsius' %(fahrenheit,celsius))
The above code returns the following output -
Related Articles
Python send mail to multiple recipients using SMTP serverHow to generate QR Code in Python using PyQRCode
Python programs to check Palindrome strings and numbers
CRUD operations in Python using MYSQL Connector
Fibonacci Series Program in Python
Python File Handler - Create, Read, Write, Access, Lock File
Python convert XML to JSON
Python convert xml to dict
Python convert dict to xml
Alphabetical order Python
Program to read two numbers, print their quotient & remainder in python
ASCII value in Python
Greatest common divisor (GCD) in Python
Python nonlocal keyword
Prime factor Python