Bird
0
0

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

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

    The colon : means select all rows, and 1 means select the second column (indexing starts at 0).
  2. Step 2: Apply slicing to the array

    This selects every row but only the second column from each row.
  3. Final Answer:

    Selects all rows and the second column -> Option A
  4. Quick Check:

    Slicing rows and columns = Select all rows, column 1 [OK]
Quick Trick: Colon means all rows or columns, number means specific index [OK]
Common Mistakes:
  • Confusing row and column indices
  • Using 1-based indexing instead of 0-based
  • Forgetting colon means all elements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes