Complete the code to import the NumPy library with the common alias.
import [1] as np
NumPy is usually imported with the alias np to make code shorter and easier to read.
Complete the code to create a NumPy array from a Python list.
import numpy as np arr = np.[1]([1, 2, 3, 4])
The array function creates a NumPy array from a list or other sequence.
Fix the error in the code to get the shape of a NumPy array.
import numpy as np arr = np.array([1, 2, 3]) shape = arr.[1]
The shape attribute (without parentheses) gives the dimensions of the array.
Fill both blanks to create a 2x2 NumPy array filled with zeros.
import numpy as np zeros_array = np.[1]((2, [2]))
The zeros function creates an array filled with zeros. The shape is given as a tuple (2, 2).
Fill all three blanks to create a dictionary comprehension that maps each word to its length if length is greater than 3.
words = ['apple', 'bat', 'car', 'door'] lengths = { [1]: [2] for [3] in words if len([3]) > 3 }
This dictionary comprehension uses word as the variable, maps it to its length with len(word), and iterates over words.