当我返回一个值时,它怎么不输出它?这可能很简单...顺便说一下,我目前还在学习Python。我使用Python 3.x.我的程序没有返回值?
def convert(operation, temp):
newTemp = 0
if (operation is 'F' or operation is 'f'):
newTemp = (9/5) * (temp + 32)
return newTemp
if (operation is 'C' or operation is 'c'):
newTemp = (5/9) * (temp - 32)
return newTemp
print ("What operation would you like to convert to? ")
op = input("(F)ahrenheit or (C)elsius: ")
print()
temp = input("What is the temperature : ")
NewTemp = int(temp)
convert(op, NewTemp)
感谢
除了'print'事情,你的华氏公式是不正确的:它应该是'9/5 *温度+ 32“(不需要括号)。 – iamnotmaynard