Recall & Review
beginner
What is multi-dimensional fancy indexing in NumPy?
It is a way to select elements from a NumPy array using arrays of indices for each dimension, allowing complex and flexible selection of elements.
Click to reveal answer
beginner
How does multi-dimensional fancy indexing differ from simple slicing?
Simple slicing uses ranges and steps to select continuous blocks, while fancy indexing uses arrays of indices to select arbitrary elements, possibly non-contiguous and repeated.
Click to reveal answer
intermediate
Given a 2D array, what happens if you use two index arrays of the same shape for fancy indexing?
NumPy selects elements at positions specified by pairs of indices from the two arrays, element-wise, producing an output array of the same shape as the index arrays.
Click to reveal answer
intermediate
Why is multi-dimensional fancy indexing useful in data science?
It allows selecting and manipulating specific elements or patterns in data arrays efficiently, which is helpful for filtering, transforming, or extracting data subsets.
Click to reveal answer
intermediate
What is the output shape when using multi-dimensional fancy indexing with index arrays of shape (3, 2)?
The output array will have the same shape (3, 2), with each element selected according to the corresponding indices in the index arrays.
Click to reveal answer
What does multi-dimensional fancy indexing allow you to do in NumPy?
✗ Incorrect
Multi-dimensional fancy indexing uses arrays of indices to select elements from each dimension.
If you have a 2D array and use two index arrays of shape (2, 3), what will be the shape of the output?
✗ Incorrect
The output shape matches the shape of the index arrays used for fancy indexing.
Which of the following is NOT true about fancy indexing?
✗ Incorrect
Fancy indexing returns a copy, not a view, of the selected elements.
What happens if index arrays used in multi-dimensional fancy indexing have different shapes?
✗ Incorrect
NumPy broadcasts index arrays to a common shape before selecting elements.
Why might you use multi-dimensional fancy indexing instead of loops?
✗ Incorrect
Fancy indexing is vectorized and usually faster than explicit loops.
Explain how multi-dimensional fancy indexing works in NumPy with an example.
Think about how you pick elements by row and column indices stored in arrays.
You got /4 concepts.
Describe the difference between slicing and multi-dimensional fancy indexing.
Consider how you select elements in a list versus picking specific positions.
You got /4 concepts.