Bird
0
0

What is wrong with this code?

medium📝 Debug Q7 of 15
SciPy - Linear Algebra (scipy.linalg)
What is wrong with this code?
from scipy.sparse import eye
I = eye(3, 4)
Aeye() only accepts square matrix size
Beye() cannot create sparse matrices
CNothing is wrong with the code
Deye() needs an additional parameter for data type
Step-by-Step Solution
Solution:
  1. Step 1: Check eye() function signature

    scipy.sparse.eye(m, n=None, ...) accepts separate integer arguments m and n.
  2. Step 2: Identify if there is an error

    Passing 3 and 4 as separate arguments is correct; the function supports non-square matrices.
  3. Final Answer:

    Nothing is wrong with the code -> Option C
  4. Quick Check:

    eye(3,4) = valid non-square sparse identity [OK]
Quick Trick: Pass m, n separately to sparse.eye() [OK]
Common Mistakes:
MISTAKES
  • Assuming only square matrices
  • Thinking shape must be a tuple
  • Adding unnecessary dtype parameter

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes