1. Home
  2. Data Science
  3. NumPy
  4. Which NumPy function creates an identity matrix?

Added 16 Sep 2025

Which NumPy function creates an identity matrix?

  1. np.identity()
  2. np.eye() Correct answer
  3. np.ones()
  4. np.zeros()

Correct answer

B. np.eye()

14 views

MCQSEXAM

Explanation

np.eye() creates an identity matrix with ones on the diagonal and zeros elsewhere.

Reference

Asked in: Data Science Exams

https://numpy.org/doc/stable/reference/generated/numpy.eye.html

Preparing for an exam?

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More NumPy MCQs

Practise all NumPy MCQs

Similar MCQs