Numpy Zeros np.zeros() in Python

Numpy zeros np.zeros() function in python is used to get an array of given shape and type filled with zeros. You can pass three parameters inside function np.zeros shape, dtype and order. Numpy zeros function returns an array of the given shape.

Basic Syntax


And the parameters are:

shapelike (2,3) or 2. For (2,3) it will return an array of shape 2 by 3 and for 2 it will return an array of shape 1 by 2.
dtype(Optional) This is the desired data type for an array for example numpy.int8 or numpy.float64 which is the default.
order(Optional) The values should be ‘C’ or ‘F’. This parameter describes storing data in row-major (‘C’) or column-major (‘F’) order style in memory.

Return Value

This function will return ndarray of zeros with given shape, dtype and order.


The following are the examples for the np.zeros() function in Python.

Example 1

Matrix first:
Matrix second:

Example 2

The output should be:

[(0,0.0) (0,0.0)]


Please enter your comment!
Please enter your name here