""" Exercise 5.9 from "A primer on..." Plot a simple function """ import numpy as np import matplotlib.pyplot as plt v0 = 10 g = 9.81 t_max = 2 * v0 / g #use numpy and vectorized operations to create t and y arrays: t = np.linspace(0, t_max, 101) y = v0 * t - 0.5 * g * t**2 plt.plot(t, y) plt.xlabel('time (s)') plt.ylabel('height (m)') plt.show()