The main difference between a copy and a view of an array is that a copy creates a new array that owns its data, meaning changes to the copy do not affect the original array, while a view is a reference to the original array, so modifications to the view will impact the original, and vice versa.
Create a copy of the array, modify the original array, and then display both arrays.
import numpy as np arr = np.array([1, 2, 3, 4, 5]) x = arr.copy() arr[0] = 42 print(arr) print(x) |