def vel(y,umax,r,Rmax):
vel_p=umax*(1-(r/Rmax)**2)
if r<50:
r=50-y
else:
r=y-50
return 'the value of velocity in cell is %r,%r,%r,%r'%(umax,r,Rmax,vel_p)
def main():
y=(input('enter y'))
a=(input('enter the umax'))
#b=(input('enter the r'))
b=(r)
c=(input('enter the Rmax'))
print(vel(a,c,b,y))
main()
我不明白的地方我应该把[R它给了我没有定义如果else语句,全局名称没有定义
那么,为什么你注释掉输入“r”的行并将其替换为一个不存在的变量的引用呢? –
你也不需要围绕'input'进行括号。这看起来像它产生了一个“元组”,但它不会(忽略逗号'','),并且可能会引起混淆。 –
,因为我需要从y获得r的值,如果我不把它放在注释中,它将取我的r值,并且不会从if语句计算 – joe