""""Exercise 2.8 from "A Primer on ..." Generate a nicely formatted table of t and y values, The t values should be n + 1 equally spaced t values on the interval [a,b], and the y values are computed with the given formula. """ #a) Using a for-loop v0 = 5 g = 9.81 n = 5 a = 0 b = 2 * v0 / g h = (b - a) / n for i in range(n + 1): t = a + h * i y = v0 * t - 0.5 * g * t**2 print(f"{t:5.5f} {y:5.5f}") t = a print("#####") #b) Same task using a while-loop eps = 1e-10 while t < b + eps: #safer than using t<=b, because of roundoff error y = v0 * t - 0.5 * g * t**2 print(f"{t:5.5f} {y:5.5f}") t = t + h """ Terminal> python ball_table1.py 0.00000 0.00000 0.20387 0.81549 0.40775 1.22324 0.61162 1.22324 0.81549 0.81549 1.01937 0.00000 ##### 0.00000 0.00000 0.20387 0.81549 0.40775 1.22324 0.61162 1.22324 0.81549 0.81549 1.01937 0.00000 """