社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Python

在这个简单的Python代码中,我做错了什么?

Manan • 3 年前 • 1737 次点击  

--我的目标是制作一个代码,用户必须输入温度,然后用户必须输入单位(C或F),然后我想显示转换为F,如果用户输入C,反之亦然。这里出了什么问题请告诉我,我对python非常陌生,整天都在学习,谢谢。

print("Lets convert from C to F/ F to C")
temp = int(input("enter the temperature: "))
unit = input("enter the unit (C or F)")
if unit == C:
    F = temp * 1.8 + 32
    print(temp +"C is equal to"+F +"F")
elif unit == F:
    C = temp / 1.8 - 32
    print(temp + "F is equal to" +C + "C")
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/131513
 
1737 次点击  
文章 [ 4 ]  |  最新文章 3 年前