Challenge - High School Reunion¶

With your high school reunion fast approaching, you decide to get in shape and lose some weight. You record your weight every day for five weeks starting on a Monday.

In [1]:
%pip install numpy
import numpy as np

dailywts = 185 - np.arange(5*7)/5

print(dailywts)
Requirement already satisfied: numpy in /home/samrat/Documents/numpy-torch-tutorials/venv/lib/python3.8/site-packages (1.24.4)
Note: you may need to restart the kernel to use updated packages.
[185.  184.8 184.6 184.4 184.2 184.  183.8 183.6 183.4 183.2 183.  182.8
 182.6 182.4 182.2 182.  181.8 181.6 181.4 181.2 181.  180.8 180.6 180.4
 180.2 180.  179.8 179.6 179.4 179.2 179.  178.8 178.6 178.4 178.2]
In [3]:
dailywts = dailywts.reshape((5, 7))
dailywts
Out[3]:
array([[185. , 184.8, 184.6, 184.4, 184.2, 184. , 183.8],
       [183.6, 183.4, 183.2, 183. , 182.8, 182.6, 182.4],
       [182.2, 182. , 181.8, 181.6, 181.4, 181.2, 181. ],
       [180.8, 180.6, 180.4, 180.2, 180. , 179.8, 179.6],
       [179.4, 179.2, 179. , 178.8, 178.6, 178.4, 178.2]])
In [12]:
averages = np.mean(dailywts[:, -2:], axis=1)
averages
Out[12]:
array([183.9, 182.5, 181.1, 179.7, 178.3])