Bird
0
0

What is the issue with this code?

medium📝 Debug Q6 of 15
SciPy - Image Processing (scipy.ndimage)
What is the issue with this code?
from scipy.ndimage import gaussian_filter

img = [[5, 10], [15, 20]]
result = gaussian_filter(img, sigma=[1, 2])
print(result)
APassing sigma as a list is invalid; sigma must be a single float
BThe input image must be a numpy array, not a list
CThe gaussian_filter function does not accept 2D arrays
DThe print statement is missing parentheses
Step-by-Step Solution
Solution:
  1. Step 1: Check input type

    Gaussian filter requires numpy arrays, but img is a Python list.
  2. Step 2: Sigma parameter

    Sigma can be a scalar or sequence matching input dimensions, so sigma=[1,2] is valid.
  3. Step 3: Print statement

    Print statement syntax is correct in Python 3.
  4. Final Answer:

    Option B -> Option B
  5. Quick Check:

    Input must be numpy array, not list [OK]
Quick Trick: Input must be numpy array, not plain list [OK]
Common Mistakes:
  • Assuming sigma cannot be a list
  • Ignoring input type requirements
  • Confusing print syntax errors

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes