The numpy.zeros()
function is used to return a new array of a given shape and type filled with zeros.
The function has the following syntax:
numpy.zeros(shape, dtype=float, order='C', *, like=None)
The numpy.zeros()
function takes the following parameter values:
shape
: This represents the desired or the new array.dtype
: This represents the desired data type of array and is optional.like
: This represents the array_like
object or the prototype.The numpy.zeros()
function returns an array with the given shape and data type filled with zeros.
import numpy as np# creating a prototype or array_like object with an integer data typemy_array = np.zeros(5, dtype = int)print(my_array)
numpy
module.numpy.zeros()
function to create an array with its 5
elements set to 0
. We assigned the result to a variable my_array
.my_array
.