""" Ex 5.9 from A primer on ... Plot function y = v0*t-0.5*g*t**2 for t in [0,2*v0/g] """ import numpy as np import matplotlib.pyplot as plt v0 = 10 g = 9.81 n = 101 t_stop = 2*v0/g """ We could use this for-loop to create the t-array, but the single call to linspace below does the same job: dt = t_stop/(n-1) t = [] for i in range(n): t.append(dt*i) t = np.array(t) """ t = np.linspace(0,t_stop,n) y = v0*t - 0.5*g*t**2 plt.plot(t,y) plt.xlabel('time (s)') plt.ylabel('height (m)') plt.savefig('plot.pdf') plt.show() """ Terminal> python plot_ball1.py Output is a plot """