""" Ex 5.10 from "A primer on..." Same as ex. 5.9, but this time the v0 values are read as command line arguments. We need a for-loop to iterate over the v0 values, do the calculations, and draw the plots. """ import numpy as np import matplotlib.pyplot as plt import sys v0_list = sys.argv[1:] g = 9.81 for v0 in v0_list: v0 = float(v0) t_stop = 2 * v0 / g t = np.linspace(0, t_stop, 101) y = v0 * t - 0.5 * g * t**2 plt.plot(t, y, label = f'v0 = {v0}') plt.legend() plt.xlabel('time (s)') plt.ylabel('height (m)') plt.show()