Bird
0
0

What does the expression arr[1, 2] return when arr is a 2D numpy array?

easy📝 Conceptual Q1 of 15
NumPy - Indexing and Slicing
What does the expression arr[1, 2] return when arr is a 2D numpy array?
AThe element in the 1st row and 2nd column
BThe entire 2nd row
CThe element in the 2nd row and 3rd column
DThe entire 3rd column
Step-by-Step Solution
Solution:
  1. Step 1: Understand numpy 2D indexing

    In numpy, the first index is the row number and the second is the column number, both zero-based.
  2. Step 2: Apply the indices to the array

    Index [1, 2] means 2nd row (index 1) and 3rd column (index 2).
  3. Final Answer:

    The element in the 2nd row and 3rd column -> Option C
  4. Quick Check:

    2D array indexing = element at (row, col) [OK]
Quick Trick: Row index first, then column index in 2D arrays [OK]
Common Mistakes:
  • Confusing row and column order
  • Using 1-based indexing
  • Selecting entire row instead of element

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes