我已经多次尝试重写代码,但在第16行不断出现错误。这是我的密码:
choice = input("fc; cf; fk;?")
if (choice == 'fc'):
def fc():
fahrenheit = int(input("enter temp: "))
celsius = (fahrenheit - 32) / 1.8
print(celsius)
fc()
elif (choice == 'cf'):
def cf():
celsius = int(input("enter temp: "))
fahrenheit = (celsius * 1.8) + 32
print(fahrenheit)
cf()
elif (choice == 'fk'):
def fk():
fahrenheit = int(input("enter temp: "))
kelvin = 5/9(fahrenheit - 32) + 273
print(kelvin)
fk()
问题出在
9(fahrenheit - 32)
。Python认为这是一个函数调用,而不是乘法。运算符必须始终显式编写。你知道吗而不是
应该修好它
编辑:如果您使用的是python2.7,而不是5/9,那么它应该是5.0/9以强制浮点结果。你知道吗
相关问题 更多 >
编程相关推荐