Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to check if the drone battery is low.
Drone Programming
if battery_level [1] 20: initiate_landing()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '<' causes the drone to land when battery is high.
✗ Incorrect
The drone should initiate landing when the battery level is less than 20%.
2fill in blank
mediumComplete the code to retry connection if signal strength is weak.
Drone Programming
if signal_strength [1] 30: retry_connection()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>=' causes retry even when signal is strong.
✗ Incorrect
The drone retries connection when signal strength is less than 30.
3fill in blank
hardFix the error in the failsafe check for obstacle distance.
Drone Programming
if obstacle_distance [1] 5: stop_movement()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' causes the drone to stop when obstacle is far away.
✗ Incorrect
The drone should stop movement if obstacle distance is less than 5 meters.
4fill in blank
hardFill both blanks to create a failsafe that checks battery and signal before takeoff.
Drone Programming
if battery_level [1] 50 and signal_strength [2] 40: start_takeoff()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' for battery_level causes takeoff with low battery.
✗ Incorrect
The drone starts takeoff only if battery is at least 50 and signal strength is greater than 40.
5fill in blank
hardFill all three blanks to create a failsafe dictionary filtering sensors with safe readings.
Drone Programming
safe_sensors = {sensor: reading for sensor, reading in sensors.items() if reading [1] [2] and reading [3] 100} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '>=' excludes zero readings.
✗ Incorrect
This dictionary comprehension keeps sensors with readings between 0 and 100 inclusive.