Bird
0
0

How can you create a 4x6 matrix with ones on the diagonal two below the main diagonal using np.eye()?

hard📝 Application Q9 of 15
NumPy - Creating Arrays
How can you create a 4x6 matrix with ones on the diagonal two below the main diagonal using np.eye()?
Anp.eye(4, 6, k=-2)
Bnp.eye(6, 4, k=2)
Cnp.eye(4, 6, k=2)
Dnp.eye(6, 4, k=-2)
Step-by-Step Solution
Solution:
  1. Step 1: Understand matrix shape and diagonal offset

    We want 4 rows and 6 columns, with diagonal shifted two below main diagonal (k=-2).
  2. Step 2: Match parameters

    np.eye(4, 6, k=-2) matches rows=4, cols=6, diagonal offset -2.
  3. Final Answer:

    np.eye(4, 6, k=-2) -> Option A
  4. Quick Check:

    Rows=4, cols=6, k=-2 for below diagonal [OK]
Quick Trick: Rows first, columns second; negative k shifts diagonal down [OK]
Common Mistakes:
  • Swapping rows and columns
  • Using positive k for below diagonal
  • Confusing matrix shape order

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes