English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

Python basic tutorial

Python flow control

Python Functions

Python Data Types

Python file operations

Python objects and classes

Python date and time

Advanced knowledge of Python

Python reference manual

Python program converts Celsius temperature to Fahrenheit temperature

Python example大全

In this program, you will learn to convert Celsius to Fahrenheit and display it.

To understand this example, you should understand the followingPython programmingTopic:

In the following program, we convert temperature from Celsius to Fahrenheit. They are associated with the following formula:

celsius * 1.8 = fahrenheit - 32

Source code

# Python program converts Celsius temperature to Fahrenheit temperature
# Change this value to get different results
celsius = 37.5
# Calculate Fahrenheit temperature
fahrenheit = (celsius * 1.8) + 32
print('%0.1f Celsius equals %0.1f Fahrenheit' %(celsius,fahrenheit))

Output result

37.5 Celsius equals 99.5 Fahrenheit

We recommend that you use the following formula to create a Python program to convert Fahrenheit temperature to Celsius temperature yourself

celsius = (fahrenheit - 32) / 1.8

Python example大全