Exercise: Arithmetics

5.3.1. Exercise: Arithmetics#

A ball is released from a point in air. Knowing that it was immobile when it was released, and that it gains negative speed at a rate of 9.81 m/s², plot a curve of its velocity as shown in Fig. 5.5 during one second from release time.

Fig. 5.5 Vertical velocity of a falling ball.#

Tip

Start by creating a time array using np.arange or np.linspace. Then, use this time array to create a velocity array. Finally, plot the velocity as a function of time.

Hide code cell content
import numpy as np
import matplotlib.pyplot as plt


# First, let's define a time array
t = np.linspace(0, 1, 100, endpoint=False)

# Calculate the velocity as -9.81 * t
v = -9.81 * t

# Show it
plt.plot(t, v)
plt.xlabel("Time (s)")
plt.ylabel("Velocity (m/s)")
plt.grid(True)
plt.show()
_images/2b5dcf4d56dad0ff909673a3d489b69b02bc53e930897ff6ac72c8165ea43736.png