🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.a[0] also becomes 99, because a slice is a view of the same data
  2. B.Nothing, because slices are always copies
  3. C.NumPy raises an error
  4. 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 →