Bird
0
0

If you modify a slice of a NumPy array, what happens to the original array?

easy📝 Conceptual Q2 of 15
NumPy - Indexing and Slicing
If you modify a slice of a NumPy array, what happens to the original array?
AThe original array is also modified
BThe original array remains unchanged
CAn error is raised
DThe slice becomes a copy automatically
Step-by-Step Solution
Solution:
  1. Step 1: Recall that slicing returns a view

    The slice shares the same data as the original array.
  2. Step 2: Understand effect of modifying the slice

    Changing the slice changes the original array because they share data.
  3. Final Answer:

    The original array is also modified -> Option A
  4. Quick Check:

    Modifying slice affects original = C [OK]
Quick Trick: Modifying a view changes the original array too [OK]
Common Mistakes:
  • Assuming slice is independent copy
  • Expecting no change in original
  • Confusing views with copies

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes