Complete the code to create a 1D array of length 5 filled with ones.
import numpy as np array = np.[1](5) print(array)
The np.ones() function creates an array filled with ones.
Complete the code to create a 2x3 array filled with ones.
import numpy as np array = np.ones([1]) print(array)
The shape argument for a 2 rows and 3 columns array is (2, 3).
Fix the error in the code to create a 3x3 array of ones with integer type.
import numpy as np array = np.ones((3, 3), dtype=[1]) print(array)
The dtype argument expects a string like 'int' to specify integer type.
Fill both blanks to create a 4x4 array of ones with float type and print its shape.
import numpy as np array = np.ones([1], dtype=[2]) print(array.shape)
The shape should be (4, 4) for a 4x4 array, and dtype 'float' specifies floating point numbers.
Fill all three blanks to create a 2x5 array of ones with integer type and print the array.
import numpy as np array = np.ones([1], dtype=[2]) print([3])
The shape is (2, 5), dtype is 'int' for integers, and printing the variable array shows the result.