Zeros Matrix using numpy.zeros() | Linear Algebra using Python

Linear Algebra using Python | Zeros Matrix using numpy.zeros(): Here, we are going to learn about creating zeros matrix using numpy.zeros() in Python.
Submitted by Anuj Singh, on May 29, 2020

Zeros Matrix - When all the entries of a matrix are one, then it is called a zeros matrix. It may be of any dimension (MxN).

Properties:

  • The determinant of the matrix is 0.
  • The Rank of any zeros Matrix is 1.

In python, we have an inbuilt function (defined in numpy library) numpy.zeros() to define the zeros matrix. Here is the code with examples.

Python code for zeros matrix using numpy.zeros()

# Linear Algebra Learning 
# Zeros Matrix

import numpy as np

a = np.zeros([3,5])
b = np.zeros([6,6])
c = np.zeros([9,5])

#printing the matrices
print("\n----Zeros Matrix (3x5)----\n",a)
print("\n----Zeros Matrix (9x5)----\n",c)
print("\n----Zeros Matrix (6x6)----\n",b)

Output:

----Zeros Matrix (3x5)----
 [[0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]]

----Zeros Matrix (9x5)----
 [[0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0.]]

----Zeros Matrix (6x6)----
 [[0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0.]
 [0. 0. 0. 0. 0. 0.]]



Comments and Discussions!

Load comments ↻






Copyright © 2024 www.includehelp.com. All rights reserved.