2013-05-26 93 views
0

当我返回一个值时,它怎么不输出它?这可能很简单...顺便说一下,我目前还在学习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

除了'print'事情,你的华氏公式是不正确的:它应该是'9/5 *温度+ 32“(不需要括号)。 – iamnotmaynard

回答

0

你从来没有告诉它打印的结果。试试这个:

print(convert(op, NewTemp)) 
+0

谢谢!那帮了很多,不好意思,下次 – bgschreff

0

您需要printconvert(op, NewTemp)返回值:

print(convert(op, NewTemp)) 
+0

谢谢!我习惯于其他语言,它只是自己打印。我不得不记住下次 – bgschreff