Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
SciPy - Linear Algebra (scipy.linalg)
Identify the error in this code snippet:
import numpy as np
from scipy.linalg import det
C = np.array([1, 2, 3])
print(det(C))
ASyntax error in array definition
BMissing import for numpy
CInput is not a square matrix
Ddet function does not exist in scipy.linalg
Step-by-Step Solution
Solution:
  1. Step 1: Check input type for determinant

    Determinant requires a square matrix; C is a 1D array (vector).
  2. Step 2: Confirm error cause

    Passing a vector causes an error because det expects 2D square array.
  3. Final Answer:

    Input is not a square matrix -> Option C
  4. Quick Check:

    Non-square input causes error [OK]
Quick Trick: Det needs square matrix input [OK]
Common Mistakes:
MISTAKES
  • Passing 1D array instead of 2D
  • Assuming det works on vectors
  • Ignoring input shape requirements

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes