I'm doing a project on projectile motion where I have to create a program that given some values, it will give several values. I haven't finished it yet, but I wish to test it, but I have very little knowledge on how to run my programs. I created a file on Notepad++ with some of my code, but every time I try to run it, it says:
Traceback (most recent call last):
File <"stdin">, line 1, in
ImportError: no module named py
The thing is, I don't see anywhere how to run my programs on Python using Notepad++ so I am confused as to what I have to do. I am using the command prompt to run my program. I will post what I have so far of my project because maybe it's a problem of what I have written. This is what I have so far:
"""Mini-Project about projectile motion."""
USER = ""
USER_ID = ""
import numpy as np
#Define variables for ease of use:
g = 9.81 #gravitational constant
u = (float(raw_input("enter launch_speed: ")))#speed of launch
r = (float(raw_input("enter launch_angle_deg: "))*(np.pi)/180) #angle of launch in radians
n = (float(raw_input("enter num_samples: "))) #number of time divisions
#"t" variable of time
#"x" variable of horizontal distance
#"y" variable of vertical distance
def x(t):
"""function that gives the horizontal position "x" as a function
of time.
"""
return u*(np.cos(r))*t #formula for horizontal displacement
def y(t):
"""function that gives the vertical position "y" as a function of
time.
"""
return u*(np.sin(r))*t - (g/2)*t**2 #formula for vertical displacement
def y(x):
"""function that gives the vertical position "y" as a function of the
horizontal position "x".
"""
return x*(np.tan(r))-(g/2)*(x/(u*np.cos(r)))**2
a = np.arange(1, n+1, dtype=float)
def trajectory(launch_speed, launch_angle_deg , num_samples ):
"""This function gives the values of horizontal x-values, vertical
y-values, and time values, respectively, given the values for initial
launch speed, and the angle at which it is launched, for some given
divisions of time that the object is in the air.
"""
while t <= (u*(np.sin(r))/g): #maximum time given by this formula
t = x/(u*(np.cos(r)))