How to Create a 3X3 Identity Matrix in Python

How to Create a 3X3 Identity Matrix in Python | Previously we have developed programs to create a matrix in Python now, we will discuss how to create a 3×3 identity matrix in Python. Matrix is a rectangular table arranged in the form of rows and columns, in the programming world we implement matrix by using arrays by classifying it as 1D and 2D arrays. In this section, there are some examples to create a 3×3 identity matrix in python.

How to Create a 3X3 Identity Matrix in Python

A 3X3 matrix is a matrix that has 3 rows and 3 columns, and an identity matrix is a matrix whose diagonal elements are always 1. The function np.identity() itself creates an identity matrix of 3 rows and 3 columns.

import numpy as np
m = np.identity(3)
print(m)

Output:

[[1. 0. 0.]
[0. 1. 0.]
[0. 0. 1.]]

Python Program Examples

Python Programs for Searching

Python String Programs

Leave a Comment

Your email address will not be published. Required fields are marked *