Python Celsius to Fahrenheit
The following example demonstrates how to convert Celsius to Fahrenheit:
Example
# -*- coding: UTF-8 -*-
# Filename : test.py
# author by : www.example.com
# User inputs Celsius temperature
# Receive user input
celsius = float(input('Enter Celsius temperature:'))
# Calculate Fahrenheit temperature
fahrenheit = (celsius * 1.8) + 32
print('%0.1f Celsius temperature converted to Fahrenheit is %0.1f' %(celsius,fahrenheit))
The output of executing the above code is:
输入摄氏温度: 38 38.0 摄氏温度转为华氏温度为 100.4
In the above example, the formula for converting Celsius to Fahrenheit is celsius * 1.8 = fahrenheit - 32. Therefore, the following equation is obtained:
celsius = (fahrenheit - 32) / 1.8Other Extensions
Python3 Examples