【发布时间】:2016-06-11 19:50:37
【问题描述】:
我是编程新手,所以这个问题可能很愚蠢。
我需要将Tr1 的值引入Bzero1 函数。当我运行模块时,我得到以下结果:
。
程序没有运行Bzero1 函数,我不知道为什么。是因为我没有正确引入Tr1 值还是其他原因?我希望Bzero1 执行0.083-(0.422/Tr1**1.6) 操作,Tr1 从T/Tc1 的结果中获得。
非常感谢您的帮助。
T = float(input("Introduce system temperature in Kelvin: "))
print("System temperature is: ", T)
Tc1 = float(input("Introduce critical temperature of component 1: "))
print("Critical temperature of component 1 is: ", Tc1)
def Tr1(T, Tc1):
print("Relative temperature 1: ", T/Tc1)
Tr1 = Tr1(T, Tc1)
def Bzero1(Tr1):
print("Bzero 1: ", 0.083-(0.422/Tr1**1.6))
【问题讨论】:
-
你永远不会调用
Bzero1函数。 -
您还将名称
Tr1(一个函数)` 替换为该函数的返回值。但是您的函数从不显式返回任何内容,因此您最终会将Tr1设置为None。print()写入您的控制台或终端,它不会返回任何内容供您分配给变量。 -
请不要链接到重要信息的截图。将信息作为文本包含在您的问题中。
-
无论是文本还是文本的 .jpg 都是不敬的;感谢您提供一些东西来显示您得到的输出......
-
你将不得不解释更多你想要发生的事情,因为你的代码中有几个逻辑错误。您希望函数
Tr1返回结果吗?如果是这样,这个结果应该是什么?T/Tc1?
标签: python function parameter-passing