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

Python basic tutorial

Python flow control

Funções do Python

Tipos de Dados do Python

Python file operations

Python objects and classes

Python date and time

Python advanced knowledge

Python reference manual

Python program converts Celsius temperature 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 temperature to Fahrenheit
# 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 degree

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

celsius = (fahrenheit - 32) / 1.8

Python example大全