Python NumPy program to create a 3×3 identify matrix

In this python numpy program, we will create a 3×3 identify matrix

Steps to solve the program
  1. Import the numpy library as np.
  2. Create a 3×3 identity matrix using np.identity().
  3. Print the output.
import numpy as np
x = np.identity(3)

print(x)

Output :

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

create a 3×3 matrix.

generate random numbers between 1-2.

Leave a Comment