Bird
0
0
Raspberry Piprogramming~20 mins

Time-lapse photography in Raspberry Pi - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Time-lapse Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
1:30remaining
Output of Raspberry Pi camera capture loop
Consider this Python code snippet for a Raspberry Pi camera time-lapse. What will be printed after running this code for 3 iterations?
Raspberry Pi
import time
for i in range(3):
    print(f"Capturing image {i+1}")
    time.sleep(2)
print("Time-lapse complete")
A
Capturing image 1
Capturing image 2
Time-lapse complete
B
Capturing image 0
Capturing image 1
Capturing image 2
Time-lapse complete
C
Capturing image 1
Capturing image 2
Capturing image 3
D
Capturing image 1
Capturing image 2
Capturing image 3
Time-lapse complete
Attempts:
2 left
💡 Hint
Remember that range(3) produces 0, 1, 2 but the print uses i+1.
🧠 Conceptual
intermediate
1:00remaining
Understanding delay in time-lapse photography
Why is it important to include a delay (like time.sleep) between captures in a time-lapse script on Raspberry Pi?
ATo control the interval between images so the time-lapse plays smoothly
BTo reduce the file size of each image captured
CTo allow the camera sensor to cool down and prevent overheating
DTo automatically delete old images after capture
Attempts:
2 left
💡 Hint
Think about what happens if images are taken too quickly.
🔧 Debug
advanced
2:00remaining
Identify the error in this time-lapse capture code
What error will this Raspberry Pi Python code produce when run?
Raspberry Pi
from picamera import PiCamera
import time
camera = PiCamera()
for i in range(5):
    camera.capture('image{i}.jpg')
    time.sleep(1)
AFileNotFoundError because directory does not exist
BLogical error due to missing f-string in filename
CTypeError because capture expects bytes not string
DNo error, code runs correctly
Attempts:
2 left
💡 Hint
Look carefully at how the filename string is constructed inside capture().
Predict Output
advanced
1:30remaining
Output of nested loops in time-lapse script
What will be the output of this code snippet?
Raspberry Pi
for hour in range(2):
    for minute in range(0, 60, 30):
        print(f"Capturing at {hour:02d}:{minute:02d}")
A
03:10 ta gnirutpaC
00:10 ta gnirutpaC
03:00 ta gnirutpaC
00:00 ta gnirutpaC
B
Capturing at 00:00
Capturing at 00:30
Capturing at 01:00
Capturing at 01:30
Capturing at 02:00
Capturing at 02:30
C
Capturing at 00:00
Capturing at 00:30
Capturing at 01:00
Capturing at 01:30
D
Capturing at 00:00
Capturing at 00:30
Capturing at 01:00
Attempts:
2 left
💡 Hint
Check the ranges carefully and how many times the inner loop runs.
📝 Syntax
expert
1:30remaining
Identify the syntax error in this Raspberry Pi time-lapse script
Which option correctly identifies the syntax error in this code snippet?
Raspberry Pi
import time
from picamera import PiCamera
camera = PiCamera()
for i in range(3)
    camera.capture(f'image_{i}.jpg')
    time.sleep(2)
AMissing colon ':' after the for loop declaration
BIncorrect indentation of the camera.capture line
CMissing parentheses in the print function
DUsing single quotes inside f-string incorrectly
Attempts:
2 left
💡 Hint
Look at the for loop syntax carefully.