Q.8 How will you create an identity matrix using numpy?

Ans. In order to create the identity matrix with numpy, we will use the identity() function. Numpy is imported as np

np.identity(3)

We will obtain the output as –

array([[1., 0., 0.],
[0., 1., 0.],
[0., 0., 1.]])


Posted

in

by

Tags:

Comments

Leave a Reply

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