Easy Tutorial
❮ Python String Zfill Python Os Chmod ❯

Python Celsius to Fahrenheit Conversion

Python3 Examples

The following example demonstrates how to convert Celsius to Fahrenheit:

Example

# -*- coding: UTF-8 -*-

# Filename : test.py
# author by : www.tutorialpro.org

# User input for Celsius temperature

# Receive user input
celsius = float(input('Enter Celsius temperature: '))

# Calculate Fahrenheit temperature
fahrenheit = (celsius * 1.8) + 32
print('%0.1f Celsius temperature converts to Fahrenheit as %0.1f ' %(celsius,fahrenheit))

Execution of the above code results in:

Enter Celsius temperature: 38
38.0 Celsius temperature converts to Fahrenheit as 100.4

In the above example, the formula for converting Celsius to Fahrenheit is celsius * 1.8 = fahrenheit - 32. Hence, we get the following equation:

celsius = (fahrenheit - 32) / 1.8

Python3 Examples

❮ Python String Zfill Python Os Chmod ❯