A squirrel walks along a telephone cable, occasionally stopping, even turning back once before proceeding.
The squirrel's position as a function of time is shown in Figure below.

a) What is the average speed for the entire time shown, 0<t<30 s?
b) The average velocity for the entire time?
| The time of the part | The displacement of the part |
| $$\Delta t_1 = 8s$$ | $$\Delta s_1=6m$$ |
| $$\Delta t_2 = 4s$$ | $$\Delta s_2=0m$$ |
| $$\Delta t_3 = 6s$$ | $$\Delta s_3=6m$$ |
| $$\Delta t_4 = 2s$$ | $$\Delta s_4=0m$$ |
| $$\Delta t_5 = 2s$$ | $$\Delta s_5=-2m$$ |
| $$\Delta t_6 = 2s$$ | $$\Delta s_6=0m$$ |
| $$\Delta t_7 = 6s$$ | $$\Delta s_7=6m$$ |
import numpy as np
t = 8 + 4 + 6 + 2 + 2 + 2 + 6
d_s = 6 + 0 + 6 + 0 - 2 + 0 + 6
s = 6 + 0 + 6 + 0 + 2 + 0 + 6
v_v = d_s / t
v_s = s/t
print(f'a) The squarel\'s average speed is: {v_s:.2f} m/s')
print(f'b) The squarel\'average velocity is: {v_v:.2f} m/s')