Complete the code to create a NumPy array named 'arr' with values from 1 to 5.
import numpy as np arr = np.array([1])
The correct way to create a NumPy array with specific values is to pass a list of those values to np.array(). Here, [1, 2, 3, 4, 5] is a list.
Complete the code to create a new variable 'ref' that references the same NumPy array as 'arr'.
ref = [1]Assigning ref = arr makes ref point to the same array object as arr. No new array is created.
Fix the error in the code to delete the original array and check if 'ref' still exists.
import gc arr = np.array([1, 2, 3]) ref = arr [1] # Delete arr print(ref)
Using del arr removes the name arr but does not delete the array if other references exist. ref still points to the array.
Fill both blanks to create a copy of 'arr' and then delete the original reference.
copy_arr = arr[1]() del [2]
Calling arr.copy() creates a new array copy. Then deleting arr removes the original reference but copy_arr remains.
Fill all three blanks to create a view of 'arr', modify it, and then check if 'arr' changed.
view_arr = arr[1]() view_arr[0] = [2] print(arr[0] == [3])
Creating a view with arr.view() means changes to view_arr affect arr. Setting view_arr[0] = 10 changes arr[0] to 10, so the print outputs True.