我想在這個程序中繪製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