Recall & Review
beginner
What is a view in NumPy?
A view is a new array object that looks at the same data of the original array. Changes to the view affect the original array because they share the same data in memory.
Click to reveal answer
beginner
What is a copy in NumPy?
A copy is a new array object with its own separate data. Changes to the copy do not affect the original array because the data is stored independently.
Click to reveal answer
beginner
How can you create a copy of a NumPy array explicitly?
Use the
copy() method, like new_array = original_array.copy(). This creates a new array with its own data.Click to reveal answer
intermediate
What happens if you slice a NumPy array?
Slicing usually creates a view, not a copy. The sliced array shares the same data as the original, so modifying it changes the original array too.
Click to reveal answer
intermediate
Why is understanding view vs copy important in NumPy?
Because it helps avoid unexpected bugs. If you think you have a copy but actually have a view, changes might affect your original data unintentionally.
Click to reveal answer
What does slicing a NumPy array usually return?
✗ Incorrect
Slicing returns a view that shares the same data with the original array.
Which method creates a copy of a NumPy array?
✗ Incorrect
The copy() method creates a new array with its own data.
If you modify a view, what happens to the original array?
✗ Incorrect
Since a view shares data with the original, changes to the view affect the original array.
How can you avoid modifying the original array when working with slices?
✗ Incorrect
Using copy() creates an independent array, so changes won't affect the original.
Which of these is true about views in NumPy?
✗ Incorrect
Views share the same data buffer with the original array.
Explain the difference between a view and a copy in NumPy with an example.
Think about memory sharing and changes reflecting back.
You got /4 concepts.
Why might accidentally working with a view instead of a copy cause bugs in your data analysis?
Consider what happens when you change data you didn't mean to.
You got /3 concepts.