Bird
0
0

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

easy📝 Conceptual Q11 of 15
NumPy - Creating Arrays
What does the function np.eye(4) create in NumPy?
AA 4x4 identity matrix with 1s on the main diagonal
BA 4x4 matrix filled with zeros
CA 4x4 matrix filled with ones
DA 4x4 diagonal matrix with 1s on the first upper diagonal
Step-by-Step Solution
Solution:
  1. Step 1: Understand np.eye() default behavior

    By default, np.eye(n) creates an n x n identity matrix with 1s on the main diagonal and 0s elsewhere.
  2. Step 2: Apply np.eye(4)

    Calling np.eye(4) creates a 4x4 matrix with 1s on the main diagonal and 0s elsewhere.
  3. Final Answer:

    A 4x4 identity matrix with 1s on the main diagonal -> Option A
  4. Quick Check:

    np.eye(4) = 4x4 identity matrix [OK]
Quick Trick: np.eye(n) makes nxn identity matrix by default [OK]
Common Mistakes:
  • Confusing np.eye() with np.ones() or np.zeros()
  • Thinking np.eye() fills all elements with 1
  • Assuming 1s are on an off-diagonal by default

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes