BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

Python Program to Convert Celsius To Fahrenheit and Vice Versa

Last Updated: May 30, 2019 by Chaitanya Singh | Filed Under: Python Examples

In this tutorial, we will write Python programs to convert Celsius To Fahrenheit and Vice Versa.

Celsius To Fahrenheit and Fahrenheit to Celsius conversion formulas

Celsius and Fahrenheit are the measurement units of Temperature. Let’s see the conversion formulas to convert temperature in degree Celsius to degree Fahrenheit and vice versa.

Celsius = (Fahrenheit – 32) * 5/9
Fahrenheit = (Celsius * 9/5) + 32

To understand the following programs, you must have the basic knowledge of following Python concepts:
1. Python Input/Output
2. Python Data Types

Program to Convert Celsius To Fahrenheit

In the following program we are taking the input from user, user enters the temperature in Celsius and the program converts the entered value into Fahrenheit using the conversion formula we have seen above.

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

Output:
Program to Convert Celsius To Fahrenheit

Program to Convert Fahrenheit to Celsius

In the following program user enters the temperature in Fahrenheit and the program converts the entered value into Celsius using the Fahrenheit to Celsius conversion formula.

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

Output:
Program to Convert Fahrenheit to Celsius

Top Related Articles:

  1. Python Program to Generate a Random Number
  2. Python Program to Check if a Number is Positive Negative or Zero
  3. Python Program to Convert Kilometers(km) to Miles(mi.)
  4. Python Program to Find ASCII Value of a Character
  5. Python Program to Print Hello World

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Leave a Reply Cancel reply

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

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap