Recall & Review
beginner
What does aggregation along a specific axis mean in numpy?
It means combining values in an array along a chosen direction (axis), like summing all rows or columns separately.
Click to reveal answer
beginner
How do you sum all elements in each column of a 2D numpy array?
Use
np.sum(array, axis=0). Axis 0 means moving down rows, summing column-wise.Click to reveal answer
beginner
What is the difference between
axis=0 and axis=1 in numpy aggregation?axis=0 aggregates down the rows (column-wise), axis=1 aggregates across columns (row-wise).Click to reveal answer
beginner
How to find the maximum value in each row of a 2D numpy array?
Use
np.max(array, axis=1). This finds the max value moving across columns for each row.Click to reveal answer
beginner
Why is specifying the axis important in numpy aggregation functions?
Because it tells numpy which direction to combine values, affecting the shape and meaning of the result.
Click to reveal answer
What does
np.sum(array, axis=0) do on a 2D array?✗ Incorrect
Axis 0 means summing down rows, so each column's values are added together.
If you want to find the minimum value in each row, which axis should you use?
✗ Incorrect
Axis 1 moves across columns, so it finds the min value in each row.
What shape will the result have after
np.mean(array, axis=1) on a 2D array with shape (4,5)?✗ Incorrect
Aggregating along axis 1 reduces columns, so result shape is (4,), one mean per row.
Which numpy function can you use to get the sum of all elements regardless of axis?
✗ Incorrect
Without axis, np.sum adds all elements into a single number.
What happens if you use an invalid axis number in numpy aggregation?
✗ Incorrect
Numpy raises an error because the axis does not exist in the array shape.
Explain how aggregation along axis 0 and axis 1 differ in a 2D numpy array.
Think about summing columns vs summing rows.
You got /4 concepts.
Describe why specifying the axis is important when using numpy aggregation functions.
Consider what happens if you don't specify axis.
You got /4 concepts.