Bird
0
0
Raspberry Piprogramming~10 mins

Motion detection with camera in Raspberry Pi - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the library needed to work with the Raspberry Pi camera.

Raspberry Pi
import [1]
Drag options to blanks, or click blank then click option'
Apicamera
Btime
Cos
Dsys
Attempts:
3 left
💡 Hint
Common Mistakes
Importing unrelated libraries like 'time' or 'os' instead of 'picamera'.
2fill in blank
medium

Complete the code to start the camera preview so you can see what the camera sees.

Raspberry Pi
camera = picamera.PiCamera()
camera.[1]()
Drag options to blanks, or click blank then click option'
Aclose
Bcapture
Cstart_preview
Dstop_preview
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'capture' which takes a photo instead of showing live preview.
3fill in blank
hard

Fix the error in the code to capture an image and save it as 'image.jpg'.

Raspberry Pi
camera.capture([1])
Drag options to blanks, or click blank then click option'
A'image.jpg'
B'image.png'
Cimage.jpg
Dimage.png
Attempts:
3 left
💡 Hint
Common Mistakes
Not putting quotes around the filename causes a NameError.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that stores the length of each word longer than 3 letters.

Raspberry Pi
lengths = {word: [1] for word in words if len(word) [2] 3}
Drag options to blanks, or click blank then click option'
Alen(word)
B>
C<
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word itself as value instead of its length.
Using '<' instead of '>' in the condition.
5fill in blank
hard

Fill all three blanks to create a dictionary comprehension that stores uppercase words and their lengths only if length is greater than 4.

Raspberry Pi
result = [1]: [2] for word in words if len(word) [3] 4}
Drag options to blanks, or click blank then click option'
Aword.upper()
Blen(word)
C>
Dword
Attempts:
3 left
💡 Hint
Common Mistakes
Using the word as key without uppercase.
Using '<' instead of '>' in the condition.