以下代码中使用的公式作为标准给出,并假设对所有实数都是正确的。控制台显示
TypeError:+不支持的操作数类型:'NoneType'和'float'。
import math as m
def theta_m(i):
a=3
delta_t=1
b=3
if i==0:
return m.pi/6
else:
y=theta_m(i-1)+a*(beta(i)-beta(i-1))+delta_t*b*m.sin((beta(i-1)- theta_m(i-1)))
return y
def beta(i):
n=3
delta_t=1
theta_t=0
if i==0:
return 1.0/20.0
else:
y=beta(i-1)+(delta_t*(-m.sin(beta(i-1)-theta_t)+n*m.sin(beta(i-1)-theta_m(i-1))))/r(i-1)
return y
def r(i):
n=3
theta_t=0
delta_t=1
if i==0:
return 1
else:
y=r(i-1)+delta_t*(m.cos(beta(i-1)-theta_t)-n*(m.cos(beta(i-1)-theta_m(i-1))))
if y>1.5:
print "The missile will not hit the target"
else:
print" keep trying"