# numpy.zeros() in Python

## numpy.zeros() in Python

The numpy.zeros() function returns a new array of given shape and type, with zeros.
Syntax:

`numpy.zeros(shape, dtype = None, order = 'C')`

Parameters :

```shape : integer or sequence of integers
order  : C_contiguous or F_contiguous
C-contiguous order in memory(last index varies the fastest)
C order means that operating row-rise on the array will be slightly quicker
FORTRAN-contiguous order in memory (first index varies the fastest).
F order means that column-wise operations will be faster.
dtype : [optional, float(byDeafult)] Data type of returned array.
```

Returns :

`ndarray of zeros having given shape, order and datatype.`

Code 1 :

 `# Python Program illustrating` `# numpy.zeros method` ` ` `import` `numpy as geek` ` ` `b ``=` `geek.zeros(``2``, dtype ``=` `int``)` `print``(``"Matrix b : \n"``, b)` ` ` `a ``=` `geek.zeros([``2``, ``2``], dtype ``=` `int``)` `print``(``"\nMatrix a : \n"``, a)` ` ` `c ``=` `geek.zeros([``3``, ``3``])` `print``(``"\nMatrix c : \n"``, c)`

Output :

```Matrix b :
[0 0]

Matrix a :
[[0 0]
[0 0]]

Matrix c :
[[ 0.  0.  0.]
[ 0.  0.  0.]
[ 0.  0.  0.]]
```

Code 2 : Manipulating data types

 `# Python Program illustrating` `# numpy.zeros method` ` ` `import` `numpy as geek` ` ` `# manipulation with data-types` `b ``=` `geek.zeros((``2``,), dtype``=``[(``'x'``, ``'float'``), (``'y'``, ``'int'``)])` `print``(b)`

Output :

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

Note : zeros, unlike zeros and empty, does not set the array values to zero or random values respectively.Also, these codes won’t run on online-ID. Please run them on your systems to explore the working.

Last Updated on October 29, 2021 by admin

## Numpy cheatsheetNumpy cheatsheet

This Numpy cheatsheet is a complete guide for learning Numpy, suitable for beginners to advanced

## Numpy size() function | PythonNumpy size() function | Python

Numpy size() function | Python In Python, numpy.size() function count the number of elements along

## Multiplication of two Matrices in Single line using Numpy in PythonMultiplication of two Matrices in Single line using Numpy in Python

Multiplication of two Matrices in Single line using Numpy in Python Matrix multiplication is an

## Numpy Meshgrid functionNumpy Meshgrid function

Numpy Meshgrid function The numpy.meshgrid function is used to create a rectangular grid out of

## numpy.where() in Pythonnumpy.where() in Python

numpy.where() in Python The numpy.where() function returns the indices of elements in an input array where the

## Change data type of given numpy arrayChange data type of given numpy array

Change data type of given numpy array In this post, we are going to see

## numpy.sum() in Pythonnumpy.sum() in Python

numpy.sum() in Python numpy.sum(arr, axis, dtype, out) : This function returns the sum of array elements over

## numpy.multiply() in Pythonnumpy.multiply() in Python

numpy.multiply() in Python numpy.multiply() function is used when we want to compute the multiplication of two