私信  •  关注

Alberto Hanna

Alberto Hanna 最近创建的主题
Alberto Hanna 最近回复了
3 年前
回复了 Alberto Hanna 创建的主题 » 在这个简单的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": #small typo
    F = temp * 1.8 + 32
    print(str(temp) + "C is equal to" + str(F) + "F") # you cant do int + str
elif unit == "F":
    C = temp / 1.8 - 32
    print(str(temp) + "F is equal to" + str(C) + "C")