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

Python basic tutorial

Python flow control

Fonctions en Python

Types de données en Python

Python file operations

Python objects and classes

Python date and time

Advanced knowledge of Python

Python reference manual

Python program converts Celsius to Fahrenheit

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 to Fahrenheit
# Change this value to get different results
celsius = 37.5
# Calculate Fahrenheit temperature
fahrenheit = (celsius * 1.8) + 32
print('%0.1f 'Celsius is equal to %0.1f 'Fahrenheit: %s' % (celsius, fahrenheit))

Output result

37.5 Celsius is equal to 99.5 Fahrenheit

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

celsius = (fahrenheit - 32) / 1.8

Python example大全