Bird
0
0

Given the 2D array:

medium📝 Predict Output Q5 of 15
NumPy - Aggregation Functions
Given the 2D array:
arr = np.array([[3, 7, 2], [5, 1, 9]])
What does np.argmin(arr) return?
A4
B1
C5
D2
Step-by-Step Solution
Solution:
  1. Step 1: Flatten the array to find the minimum value index

    The array flattened is [3, 7, 2, 5, 1, 9]. The smallest value is 1.
  2. Step 2: Find the index of the minimum value in the flattened array

    1 is at index 4.
  3. Final Answer:

    4 -> Option A
  4. Quick Check:

    np.argmin(arr) = 4 (flattened index) [OK]
Quick Trick: np.argmin() returns index in flattened array for multi-dim arrays [OK]
Common Mistakes:
  • Expecting 2D index tuple
  • Confusing minimum value with index
  • Using argmax instead of argmin

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes