Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to import the camera module.
Raspberry Pi
from picamera import [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'picamera' instead of 'PiCamera'.
Using 'Camera' which is not the correct class name.
✗ Incorrect
The PiCamera class is used to control the Raspberry Pi camera.
2fill in blank
mediumComplete the code to start the camera preview.
Raspberry Pi
camera = PiCamera()
camera.[1]() Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'capture' which takes a photo, not starts preview.
Using 'preview_start' which is not a valid method.
✗ Incorrect
The method start_preview() starts the camera preview window.
3fill in blank
hardFix the error in the code to capture an image.
Raspberry Pi
camera = PiCamera() camera.capture('[1]')
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using unsupported file extensions like '.bmp' which may not be supported.
Using names that do not end with an image extension.
✗ Incorrect
The filename image.jpg is a common and valid name for saving a JPEG image.
4fill in blank
hardFill both blanks to capture an image with a delay.
Raspberry Pi
import time camera = PiCamera() camera.start_preview() time.[1](5) camera.[2]('photo.jpg') camera.stop_preview()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'pause' or 'wait' which are not valid time module functions.
Using 'start_preview' instead of 'capture' to take a photo.
✗ Incorrect
Use time.sleep(5) to wait 5 seconds before capturing with camera.capture('photo.jpg').
5fill in blank
hardFill all three blanks to capture an image with resolution set.
Raspberry Pi
import time camera = PiCamera() camera.[1] = (1920, 1080) camera.start_preview() time.[2](3) camera.[3]('high_res.jpg') camera.stop_preview()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'framerate' instead of 'resolution' to set image size.
Using 'wait' instead of 'sleep' for delay.
Using 'start_preview' instead of 'capture' to take the photo.
✗ Incorrect
Set camera.resolution to change image size, wait with time.sleep(3), then capture with camera.capture('high_res.jpg').
