Python numpy.zeros()

In this tutorial, you will learn about python numpy zeros() function. It returns an array of zeros.

 

Syntax:

the syntax of python numpy zeros function is

 

Parameter:

Numpy zeros() function can take three parameters:

  • shape: it defines the shape of the new array
  • dtype(optional): It assign a datatype to array, by default is float64
  • order(optional): C-style order in memory or F- Style order in memory. If multi-dimensional array in row major then C-style order in memory and if multi-dimensional array in column-major then F-style order in memory. By defualt , its C-style

Check examples below to understand

 

Example #1

generate a zeros array

 

 

Example #2

generate a zeros array with int data type

 

 

Example#3

creating a 2-denominational zeros array , including with 2 rows and three columns

 

 

Example#4

creating a 2-denominational zeros array with int data type , including with 2 rows and three columns

 

 

Example#5

creating a three dimensional array with int data type and F-style order

 

 

Start with Numpy

Starting With Python Numpy