The ndarray object can be constructed by using the following routines.
As the name specifies, The empty routine is used to create an uninitialized array of specified shape and data type.
The syntax is given below.
numpy.empty(shape, dtype = float, order = 'C')
It accepts the following parameters.
import numpy as np arr = np.empty((3,2), dtype = int) print(arr)
Output:
This routine is used to create the numpy array with the specified shape where each numpy array item is initialized to 0.
The syntax is given below.
numpy.zeros(shape, dtype = float, order = 'C')
It accepts the following parameters.
import numpy as np arr = np.zeros((3,2), dtype = int) print(arr)
Output:
This routine is used to create the numpy array with the specified shape where each numpy array item is initialized to 1.
The syntax to use this module is given below.
numpy.ones(shape, dtype = none, order = 'C')
It accepts the following parameters.
import numpy as np arr = np.ones((3,2), dtype = int) print(arr)
Output: