Project 9: Itinerary Copy vs. View Demo
Data Engineer
Builds on these lessons
Current Task
Objective
.copy() creates an independent array; .view() creates a new array object that still shares the original's underlying data — changing the original affects a view but not a copy.
Task: make a copy and a view of an array, mutate the original, then print both to see which one changed.
index.py
import numpy as np
original = np.array([10, 20, 30])
copy_arr = original.copy()
view_arr = original.view()
original[0] = 99
print(copy_arr[0])
print(view_arr[0])
* Hint: Correct characters turn green, incorrect ones turn red.
Live Preview
🖼️
Verify your code to see the preview