Home > Backend Development > Python Tutorial > Write temperature conversion in python

Write temperature conversion in python

Release: 2019-10-26 13:03:45
Original
9757 people have browsed it

Write temperature conversion in python

Python writes Celsius temperature to convert to Fahrenheit:

celsius = float(input('输入摄氏温度: '))
 
# 计算华氏温度
fahrenheit = (celsius * 1.8) + 32
print('%0.1f 摄氏温度转为华氏温度为 %0.1f ' %(celsius,fahrenheit))
Copy after login

Use formula:

fahrenheit = (celsius * 1.8) + 32
Copy after login

Python writes Fahrenheit temperature to convert to Celsius:

fahrenheit = float(input('输入华氏温度: '))
 
# 计算摄氏温度
celsius = (fahrenheit - 32) / 1.8
print('%0.1f 华氏温度转为摄氏温度为 %0.1f ' %(fahrenheit,celsius))
Copy after login

Formula:

celsius = (fahrenheit - 32) / 1.8
Copy after login

The above is the detailed content of Write temperature conversion in python. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template