Bird
0
0

Which parameter in np.eye(N, M, k) shifts the diagonal of ones?

easy📝 Conceptual Q2 of 15
NumPy - Creating Arrays
Which parameter in np.eye(N, M, k) shifts the diagonal of ones?
Ak
BM
CN
Ddtype
Step-by-Step Solution
Solution:
  1. Step 1: Identify parameters of np.eye()

    np.eye() takes N (rows), M (columns), and k (diagonal offset) among others.
  2. Step 2: Understand the role of k

    The parameter k shifts the diagonal of ones up or down from the main diagonal.
  3. Final Answer:

    k -> Option A
  4. Quick Check:

    Diagonal shift parameter = k [OK]
Quick Trick: Use k to move the diagonal up (positive) or down (negative) [OK]
Common Mistakes:
  • Confusing k with matrix size
  • Thinking dtype shifts diagonal
  • Mixing N and M as diagonal shift

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More NumPy Quizzes