1. Home
  2. Data Science
  3. NumPy
  4. What does the np.eye() function do in NumPy?

Added 25 Feb 2024

What does the np.eye() function do in NumPy?

  1. Creates a random array
  2. Creates an identity matrix Correct answer
  3. Calculates the dot product of two arrays
  4. Reshapes an array

Correct answer

B. Creates an identity matrix

15 views

MCQSEXAM

Explanation

The np.eye() function creates an identity matrix of the specified size, with ones on the diagonal and zeros elsewhere. This function is commonly used in linear algebra and matrix operations.

Reference

https://www.w3schools.com/python/numpy/numpy_random.asp

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