FunctionRacerProblemsRace

Age Groups

EasyNumPyPython

Sort the people into four groups: group 0 is ages under 13, group 1 is 13 to 19, group 2 is 20 to 64, and group 3 is 65 and over. Return a list of four numbers: how many people are in each group. Hint: np.digitize with the edges [13, 20, 65].

Example 1

ages [5,13,40,70,12]
returns [2,1,1,1]

Group 0: 5 and 12. Group 1: 13. Group 2: 40. Group 3: 70.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More NumPy problems