← Quiz: NumPy: all 10 questions
Quiz: NumPy · Question 8 of 10
You change b = a[0:2] and then set b[0] = 99. What happens to a?
You change b = a[0:2] and then set b[0] = 99. What happens to a?
- A.a[0] also becomes 99, because a slice is a view of the same data
- B.Nothing, because slices are always copies
- C.NumPy raises an error
- D.b becomes a list
Answer & explanation
Correct answer: a[0] also becomes 99, because a slice is a view of the same data
Use .copy() when you need an independent array.
Can you get the rest right without peeking?
Take the timed Quiz: NumPy quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →