def thrust_flow_function(M,r):
G = (1+r*math.pow(M,2))/(math.pow((1+(r-1)/2*math.pow(M,2)),(r/(r-1))))
dG = r*G*M*((2/(1+r*math.pow(M,2)))-(1/1+(r-1)/2*math.pow(M,2)))
return [round(G,5),round(dG,5)]
M = float(input())
r = float(input())
print((thrust_flow_function(float(M),float(r))))
在当前代码中,我将两个值都作为列表返回。但是,当我尝试将两个值分别返回时
return G return dG
它只给我G的值
答案 0 :(得分:1)
方括号([]
)用于表示列表。您不能像在数学中有时那样将它们用作通用括号。在计算dG
时,将它们替换为良好的旧括号,您应该可以:
dG = r*G*M*((2/(1+r*math.pow(M,2)))-(1/1+(r-1)/2*math.pow(M,2)))
# Here-----^---------------------------------------------------^
答案 1 :(得分:0)
r*G*M
产生一个float
,并且您将其乘以以下匿名list
(由于使用方括号[]
而创建)。你不能那样做。您是否要使用其他括号()
代替[]
?