Bird
0
0

Identify the error in this code snippet:

medium📝 Debug Q6 of 15
Raspberry Pi - Camera Module
Identify the error in this code snippet:
from picamera import PiCamera
camera = PiCamera()
camera.capture('image.jpg')
camera.close()
ANo error, code is correct
BMissing camera.start_preview() before capture()
Ccamera.close() should be called before capture()
Dcapture() method is misspelled
Step-by-Step Solution
Solution:
  1. Step 1: Review method usage

    The code correctly imports, creates camera, captures image, then closes camera.
  2. Step 2: Check if preview is required

    Preview is optional and not required for capture to work.
  3. Final Answer:

    No error, code is correct -> Option A
  4. Quick Check:

    Code runs fine without preview [OK]
Quick Trick: Preview is optional for capturing images [OK]
Common Mistakes:
MISTAKES
  • Thinking preview is mandatory
  • Calling close() too early
  • Misspelling capture()

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Raspberry Pi Quizzes