我想在这个程序中绘制f,但我搞砸了。有人可以看看,并告诉我我在哪里搞乱了。谢谢。在Python 2.7中绘制函数
import math
#x is the horizontal distance that the ball has traveled
g=9.81
v=raw_input('Enter an initial velocity:')
theta=raw_input('Enter the angle that the object was thrown at:')
y=raw_input('Enter the initial position of the object on the y-axis:')
t=(2*v*math.sin(theta))/g
x=(0.5)*((v*math.sin(theta))+v)*t
float(v)
float(theta)
float(y)
float(t)
f=x*math.tan(theta)-(1/(2*(v**2)))*((g(x**2))/(math.cos(theta)**2))+y
figure(1)
clf()
plot(f)
xlabel('x')
ylabel('y')
show()
对于初学者,您可以使用'raw_input'读取字符串,并尝试将这些字符串用作数字。 – zero323