Create a Numpy array filled with all zeros - Python Last Updated : 19 Sep, 2025 Comments Improve Suggest changes 10 Likes Like Report In this article, we will learn how to create a Numpy array filled with all zeros, given the shape and type of array. We can use Numpy.zeros() method to do this task. Let's understand with the help of an example: Python import numpy as np # Create a 1D array of zeros with 5 elements arr = np.zeros(5) print(arr) Output[0. 0. 0. 0. 0.] Explanation:np.zeros(5) function creates a 1D array with 5 elements, all initialized to 0.By default, the data type of the array is float, so the zeros are represented as 0.0.Syntaxnumpy.zeros(shape, dtype=float, order='C')Parameters:shape: Tuple or int specifying the dimensions of the array (e.g., (rows, columns)).dtype (optional): Data type of the array (default is float).order (optional): Memory layout of the array. 'C' (row-major) or 'F' (column-major).Creating a 2D Zero ArrayThis code creates a 2D array of zeros with 3 rows and 4 columns using np.zeros(). Python import numpy as np arr = np.zeros((3, 4)) print(arr) Output[[0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.]] Explanation:np.zeros((3, 4)) function creates a 2D array with 3 rows and 4 columns.The shape of the array is specified as a tuple (3, 4).Specifying Data TypeThis example shows how to create a zero array with integer elements using the dtype parameter. Python import numpy as np arr = np.zeros((2, 3), dtype=int) print(arr) Output[[0 0 0] [0 0 0]] Explanation:Here, dtype=int argument is used to specify that the array elements should be integers.The resulting array is 2x3 (2 rows, 3 columns) with all elements as 0, but they are now integers instead of floats.Using Column-Major OrderThis code demonstrates how to create a zero array stored in column-major (Fortran-style) order using the order parameter. Python import numpy as np arr = np.zeros((2, 3), order='F') print(arr) Output[[0. 0. 0.] [0. 0. 0.]] Explanation:By default, NumPy arrays are stored in row-major order (C order). However, specifying order='F' changes this to column-major order (Fortran-style).In column-major order, elements in the same column are stored contiguously in memory. Create Quiz Comment S Shivam_k Follow 10 Improve S Shivam_k Follow 10 Improve Article Tags : Python Python-numpy Explore Python FundamentalsPython Introduction 2 min read Input and Output in Python 4 min read Python Variables 4 min read Python Operators 4 min read Python Keywords 2 min read Python Data Types 8 min read Conditional Statements in Python 3 min read Loops in Python - For, While and Nested Loops 5 min read Python Functions 5 min read Recursion in Python 4 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 4 min read Python Tuples 4 min read Python Dictionary 3 min read Python Sets 6 min read Python Arrays 7 min read List Comprehension in Python 4 min read Advanced PythonPython OOP Concepts 11 min read Python Exception Handling 5 min read File Handling in Python 4 min read Python Database Tutorial 4 min read Python MongoDB Tutorial 2 min read Python MySQL 9 min read Python Packages 10 min read Python Modules 7 min read Python DSA Libraries 15 min read List of Python GUI Library and Packages 3 min read Data Science with PythonNumPy Tutorial - Python Library 3 min read Pandas Tutorial 4 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library - Tutorial 3 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 6 min read Web Development with PythonFlask Tutorial 8 min read Django Tutorial | Learn Django Framework 7 min read Django ORM - Inserting, Updating & Deleting Data 4 min read Templating With Jinja2 in Flask 6 min read Django Templates 5 min read Python | Build a REST API using Flask 3 min read How to Create a basic API using Django Rest Framework ? 4 min read Python PracticePython Quiz 1 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like