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/01980f8f6426156ef28aeee04ff50de55b36fa8a79ac724c2403ff6c5812f0e0.png