def gettrajectorydata(filename)datafile open(filename' 'distances [heights heights heights heights [],[],[],[discardheader datafile readline(for line in datafiledh line split(distances append(float( )heights append(float( )heights append(float( )heights append(float( )heights append(float( )datafile close(return (distances[heights heights heights heights ]def processtrajectories(filename)distancesheights gettrajectorydata(filenamenumtrials len(heightsdistances pylab array(distances#get array containing mean height at each distance totheights pylab array([ ]*len(distances)for in heightstotheights totheights pylab array(hmeanheights totheights/len(heightspylab title('trajectory of projectile (mean of 'str(numtrialstrials)'pylab xlabel('inches from launch point'pylab ylabel('inches above launch point'pylab plot(distancesmeanheights'bo' , pylab polyfit(distancesmeanheights altitudes *distances pylab plot(distancesaltitudes' 'label 'linear fit' , , pylab polyfit(distancesmeanheights altitudes *(distances** *distances pylab plot(distancesaltitudes' :'label 'quadratic fit'pylab legend(figure plotting the trajectory of projectile quick look at the plot on the right makes it quite clear that quadratic fit is far better than linear one (the reason that the quadratic fit is not smooth is that we are only plotting the predicted heights that correspond to the measured heights but just how bad fit is the line and how good is the quadratic fit don' be misled by this plot into thinking that the projectile had steep angle of ascent it only looks that way because of the difference in scale between the vertical and horizontal axes on the plot