Complete the code to save a NumPy array to a file.
import numpy as np arr = np.array([1, 2, 3, 4, 5]) np.save('my_array.npy', [1])
The np.save function saves the array passed as the second argument. Here, arr is the array we want to save.
Complete the code to load a saved NumPy array from a file.
import numpy as np loaded_arr = np.[1]('my_array.npy')
np.save instead of np.load.The np.load function loads a saved NumPy array from a file.
Fix the error in the code to correctly save a NumPy array.
import numpy as np arr = np.array([10, 20, 30]) np.save('data.npy', [1])
np.array instead of the variable.The variable holding the array is arr. Passing arr to np.save correctly saves the array.
Fill both blanks to create a dictionary comprehension that saves lengths of words longer than 3 characters.
words = ['apple', 'bat', 'carrot', 'dog'] lengths = {word: [1] for word in words if len(word) [2] 3}
The dictionary comprehension maps each word to its length using len(word). The condition filters words with length greater than 3 using >.
Fill all three blanks to create a dictionary comprehension that saves uppercase words with length greater than 3.
words = ['apple', 'bat', 'carrot', 'dog'] result = { [1]: [2] for word in words if len(word) [3] 3 }
The dictionary comprehension uses the uppercase word as the key (word.upper()) and the original word as the value. It filters words with length greater than 3 using >.