Create a Numpy array filled with all zeros - Python Last Updated : 12 Jul, 2025 Comments Improve Suggest changes Like Article 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 array_1d = np.zeros(5) print(array_1d) 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.Table of ContentSyntax of Creating a NumPy Array filled with all zeros Creating a 2D Zero ArraySpecifying Data TypeUsing Column-Major OrderSyntax of Creating a NumPy Array filled with all zeros numpy.zeros(shape, dtype=float, order='C')Parametersshape: 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 Array Python import numpy as np # Create a 2D array of zeros (3 rows, 4 columns) array_2d = np.zeros((3, 4)) print(array_2d) Output[[0. 0. 0. 0.] [0. 0. 0. 0.] [0. 0. 0. 0.]] Explnation: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 Type Python import numpy as np # Create an integer zero array array_int = np.zeros((2, 3), dtype=int) print(array_int) Output[[0 0 0] [0 0 0]] Explanation:Here, the 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 Order Python import numpy as np # Create an array with column-major order array_column_major = np.zeros((2, 3), order='F') print(array_column_major) 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. Comment More info S Shivam_k Follow Improve Article Tags : Python Python-numpy Explore Python FundamentalsPython Introduction 3 min read Input and Output in Python 4 min read Python Variables 5 min read Python Operators 5 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 7 min read Python Functions 5 min read Recursion in Python 6 min read Python Lambda Functions 5 min read Python Data StructuresPython String 5 min read Python Lists 5 min read Python Tuples 4 min read Dictionaries in Python 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 12 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 6 min read Matplotlib Tutorial 5 min read Python Seaborn Tutorial 15+ min read StatsModel Library- Tutorial 4 min read Learning Model Building in Scikit-learn 8 min read TensorFlow Tutorial 2 min read PyTorch Tutorial 7 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 7 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 3 min read Python Coding Practice 1 min read Python Interview Questions and Answers 15+ min read Like