Bird
0
0

What does the slicing notation array[1:3, 0:2] do on a 2D NumPy array?

easy📝 Conceptual Q11 of 15
NumPy - Indexing and Slicing
What does the slicing notation array[1:3, 0:2] do on a 2D NumPy array?
ASelects rows 1 and 2, and columns 0 and 1
BSelects rows 0 to 3 and columns 0 to 2
CSelects rows 1 to 3 and columns 0 to 2
DSelects rows 1 and 3, and columns 0 and 2
Step-by-Step Solution
Solution:
  1. Step 1: Understand row slicing 1:3

    This means select rows starting at index 1 up to but not including index 3, so rows 1 and 2.
  2. Step 2: Understand column slicing 0:2

    This means select columns starting at index 0 up to but not including index 2, so columns 0 and 1.
  3. Final Answer:

    Selects rows 1 and 2, and columns 0 and 1 -> Option A
  4. Quick Check:

    Slice end is excluded = A [OK]
Quick Trick: Remember end index is excluded in slicing [OK]
Common Mistakes:
  • Including the end index in the slice
  • Confusing rows and columns order
  • Using commas incorrectly in slicing

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes