当我返回一个值时,怎么不输出它?它可能非常简单......顺便说一句,我目前仍在学习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)
由于
答案 0 :(得分:0)
你从未告诉它打印结果。试试这个:
print(convert(op, NewTemp))
答案 1 :(得分:0)
您需要print
convert(op, NewTemp)
返回的值:
print(convert(op, NewTemp))