Complete the code to print the number of dimensions of the array.
import numpy as np arr = np.array([[1, 2], [3, 4]]) print(arr.[1])
The ndim attribute tells how many dimensions the array has.
Complete the code to print the total number of elements in the array.
import numpy as np arr = np.array([1, 2, 3, 4, 5]) print(arr.[1])
The size attribute gives the total number of elements in the array.
Complete the code to print the data type of the array elements.
import numpy as np arr = np.array([1, 2, 3]) print(arr.[1])
The dtype attribute gives the data type of the array elements.
Fill both blanks to print the number of rows and columns of the array.
import numpy as np arr = np.array([[1, 2, 3], [4, 5, 6]]) print(arr.[1][0], arr.[2][1])
The shape attribute returns a tuple of the array dimensions. shape[0] is the number of rows, shape[1] is the number of columns.
Fill all three blanks to compute the total number of elements by multiplying the dimensions.
import numpy as np arr = np.zeros((2, 3, 4)) print(arr.[1][0] * arr.[2][1] * arr.[3][2])
The product of the values in the shape tuple gives the total number of elements (2 * 3 * 4 = 24).