Bird
0
0

Identify the error in the following code snippet:

medium📝 Debug Q6 of 15
SciPy - Image Processing (scipy.ndimage)
Identify the error in the following code snippet:
from scipy.ndimage import zoom
zoomed_img = zoom(img, zoom=2, order=2)
AMissing import for numpy
BOrder=2 is not a valid interpolation order
CThe 'zoom' parameter should not be named; it is positional
DThe zoom factor must be less than 1
Step-by-Step Solution
Solution:
  1. Step 1: Check function parameter usage

    scipy.ndimage.zoom expects the zoom factor as a positional argument, not as a keyword argument named 'zoom'.
  2. Step 2: Validate other parameters

    Order=2 is valid (quadratic interpolation), numpy import is not required here, and zoom factor can be any positive number.
  3. Final Answer:

    The 'zoom' parameter should not be named; it is positional -> Option C
  4. Quick Check:

    Zoom factor is positional argument [OK]
Quick Trick: Pass zoom factor positionally, not as 'zoom=' keyword [OK]
Common Mistakes:
  • Using 'zoom=' keyword argument
  • Thinking order=2 is invalid
  • Assuming zoom factor must be <1

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More SciPy Quizzes