1. Home
  2. Data Science
  3. NumPy
  4. What is the output of np.eye(3)?

Added 24 Feb 2024

What is the output of np.eye(3)?

  1. Identity matrix of order 3 Correct answer
  2. Array of zeros with diagonal ones
  3. Array of ones with diagonal zeros
  4. Array of ones with all elements zeros

Correct answer

A. Identity matrix of order 3

11 views

MCQSEXAM

Explanation

np.eye(3) returns the identity matrix of order 3: a 3×3 array with ones on the main diagonal and zeros everywhere else.

Multiplying any 3×3 matrix by it leaves that matrix unchanged. np.identity(3) gives the same result.

Practise more Data Science MCQs with answers and explanations on MCQsExam.com.

Doubts & discussion

Not sure why the answer is A? 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