Complete the code to import the numpy module with its common alias.
import [1] as np
We import the numpy library using the name numpy. The alias np is used for convenience.
Complete the code to create a numpy array from a Python list.
arr = np.[1]([1, 2, 3, 4])
list instead of array.asarray which also works but is less common for direct creation.The np.array() function creates a numpy array from a Python list.
Fix the error in the code to apply a generalized ufunc that adds 1 to each element.
result = np.add(arr, [1])The second argument to np.add should be the scalar 1 to add 1 to each element.
Fill both blanks to create a generalized ufunc that multiplies each element by 2 and then adds 3.
step1 = np.multiply(arr, [1]) result = np.add(step1, [2])
First multiply each element by 2, then add 3 to each element.
Fill all three blanks to create a dictionary comprehension that maps each word to its length if length is greater than 3.
lengths = { [1]: [2] for [1] in words if [2] [3] 3 }The dictionary comprehension maps each word to its length len(word) if the length is greater than 3.