Recall & Review
beginner
What does
np.min() do in numpy?np.min() finds the smallest value in an array or along a specified axis.
Click to reveal answer
beginner
What is the purpose of
np.max()?np.max() returns the largest value in an array or along a specified axis.
Click to reveal answer
intermediate
How do you find the minimum value in each column of a 2D numpy array?
Use np.min(array, axis=0). Axis 0 means down the rows, so it finds min per column.
Click to reveal answer
intermediate
How to find the maximum value in each row of a 2D numpy array?
Use np.max(array, axis=1). Axis 1 means across columns, so it finds max per row.
Click to reveal answer
advanced
What happens if you call
np.min() or np.max() on an empty array?It raises a ValueError because there is no data to find min or max.
Click to reveal answer
What does
np.min() return when used on a numpy array?✗ Incorrect
np.min() finds the smallest value in the array.
How do you find the maximum value in each row of a 2D numpy array named
arr?✗ Incorrect
Axis 1 means across columns, so np.max(arr, axis=1) finds max per row.
What will
np.min() do if the array is empty?✗ Incorrect
Calling np.min() on an empty array raises a ValueError.
Which axis should you use with
np.min() to find the minimum value in each column of a 2D array?✗ Incorrect
Axis 0 means down the rows, so it finds min per column.
If you want the overall maximum value in a numpy array, which function call is correct?
✗ Incorrect
np.max(array) returns the largest value in the whole array.
Explain how to use
np.min() and np.max() to find minimum and maximum values along different axes in a 2D numpy array.Think about rows and columns as directions to find min or max.
You got /4 concepts.
What error occurs if you try to find the minimum or maximum of an empty numpy array using
np.min() or np.max()? Why?Consider what happens when there is nothing to compare.
You got /3 concepts.