Q:

Write a NumPy program to create a 3x3 identity matrix, i.e. diagonal elements are 1,the rest are 0

0

Write a NumPy program to create a 3x3 identity matrix, i.e. diagonal elements are 1,the rest are 0

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

import numpy as np
x = np.eye(3)
print(x)

Sample Output:

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now