Challenge - 5 Problems
Speed Control Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output of this speed adjustment code?
Consider this snippet controlling drone speed during a mission. What will be printed?
Drone Programming
speed = 10 for waypoint in range(3): if speed > 5: speed -= 3 print(f"Speed at waypoint {waypoint}: {speed}")
Attempts:
2 left
💡 Hint
Look carefully at how speed changes inside the loop and when it stops decreasing.
✗ Incorrect
The speed starts at 10. At waypoint 0, speed > 5 so speed becomes 7. At waypoint 1, speed is 7 > 5 so speed becomes 4. At waypoint 2, speed is 4 which is not > 5, so speed stays 4.
🧠 Conceptual
intermediate1:30remaining
Which statement best describes speed control in a mission?
In drone programming, why is it important to adjust speed dynamically during a mission?
Attempts:
2 left
💡 Hint
Think about energy use and mission efficiency.
✗ Incorrect
Adjusting speed helps conserve battery and adapt to mission needs, like slowing near obstacles or speeding on clear paths.
🔧 Debug
advanced2:00remaining
What error does this speed control code raise?
Identify the error when running this code snippet:
Drone Programming
speed = 5 for i in range(3): if speed < 10: speed += 2 print(speed)
Attempts:
2 left
💡 Hint
Check the if statement syntax carefully.
✗ Incorrect
The if statement is missing a colon at the end, causing a SyntaxError.
❓ Predict Output
advanced1:30remaining
What is the final speed after this mission segment?
Given this code controlling speed increments, what is the final speed printed?
Drone Programming
speed = 3 increments = [2, -1, 4, -3] for inc in increments: speed = max(0, speed + inc) print(speed)
Attempts:
2 left
💡 Hint
Add each increment carefully and ensure speed never goes below zero.
✗ Incorrect
Speed changes: 3+2=5, 5-1=4, 4+4=8, 8-3=5. Final speed is 5.
🚀 Application
expert2:30remaining
How many speed changes occur in this mission code?
Count how many times the speed variable changes value during this mission segment:
Drone Programming
speed = 7 changes = 0 for step in range(5): new_speed = speed - step if new_speed != speed: speed = new_speed changes += 1 print(changes)
Attempts:
2 left
💡 Hint
Check each loop iteration and compare new_speed to current speed.
✗ Incorrect
Speed changes at steps 1,2,3,4 but not at step 0 because new_speed equals speed then.