Which NumPy function creates an identity matrix?
-
A
np.identity()
-
B
np.eye()
Correct answer
-
C
np.ones()
-
D
np.zeros()
Correct answer
B. np.eye()
14 views
Explanation
np.eye() creates an identity matrix with ones on the diagonal and zeros elsewhere.
Doubts & discussion
Not sure why the answer is B? Ask here and get an explanation.
Ask a doubt about this MCQ