python华氏度转摄氏度
时间: 2023-10-03 17:05:40 浏览: 81
python 将华氏温度转换为摄氏温度 示例
5星 · 资源好评率100%
要在Python中将华氏温度转换为摄氏温度,可以使用以下代码:
```python
f = float(input('请输入华氏温度:'))
c = 5/9 * (f - 32)
print('%.2f华氏度 = %.2f摄氏度' %(f,c))
```
这段代码首先要求用户输入华氏温度,然后使用转换公式将华氏温度转换为摄氏温度,最后使用print语句将结果输出。其中,%.2f表示输出一个浮点数,保留两位小数。所以,这段代码可以实现将华氏温度转换为摄氏温度并输出结果。
#### 引用[.reference_title]
- *1* [python实现摄氏温度与华氏温度的转换](https://blog.csdn.net/qq_39510537/article/details/123230644)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *2* [python-温度从华氏温度转换为摄氏温度](https://blog.csdn.net/qq_37143903/article/details/106460294)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
- *3* [python 华氏度转换摄氏度](https://blog.csdn.net/weixin_45612728/article/details/120626321)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^insertT0,239^v3^insert_chatgpt"}} ] [.reference_item]
[ .reference_list ]
阅读全文