Complete the code to create a view of the original NumPy array.
import numpy as np arr = np.array([1, 2, 3, 4]) view_arr = arr[1]
Using .view() creates a view of the original array, sharing the same data.
Complete the code to modify the view and see the change in the original array.
import numpy as np arr = np.array([10, 20, 30, 40]) view_arr = arr.view() view_arr[1] = 99 result = arr
Changing view_arr[0] modifies the original array because the view shares data.
Fix the error in the code to ensure modifying the copy does NOT change the original array.
import numpy as np arr = np.array([5, 6, 7, 8]) copy_arr = arr[1] copy_arr[0] = 100 result = arr
Using .copy() creates a new array independent of the original, so changes do not affect it.
Fill both blanks to create a dictionary with word lengths only for words longer than 3 letters.
words = ['cat', 'house', 'dog', 'elephant'] lengths = {word: [1] for word in words if [2]
The dictionary comprehension uses len(word) for values and filters words with length greater than 3.
Fill all three blanks to create a dictionary with uppercase keys and values for words longer than 3 letters.
words = ['apple', 'bat', 'carrot', 'dog'] result = [1]: [2] for w in words if [3]
The dictionary comprehension uses uppercase words as keys, original words as values, and filters words longer than 3 letters.