0
0
Drone Programmingprogramming~10 mins

Battery failsafe in Drone Programming - Interactive Code Practice

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

Complete the code to check if the battery level is below the critical threshold.

Drone Programming
if battery_level [1] critical_threshold:
    initiate_landing()
Drag options to blanks, or click blank then click option'
A>
B<
C==
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '<' causes the failsafe to trigger incorrectly.
Using '==' only triggers when battery level equals threshold, missing lower levels.
2fill in blank
medium

Complete the code to reduce drone speed when battery is low.

Drone Programming
if battery_level [1] warning_threshold:
    speed = reduced_speed
Drag options to blanks, or click blank then click option'
A<=
B!=
C==
D>=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>=' causes speed reduction when battery is high.
Using '!=' triggers speed change incorrectly.
3fill in blank
hard

Fix the error in the failsafe activation condition.

Drone Programming
if battery_level [1] critical_threshold and not is_charging:
    activate_failsafe()
Drag options to blanks, or click blank then click option'
A<
B>
C>=
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>=' triggers failsafe when battery is sufficient.
Using '>' or '>=' misses low battery cases.
4fill in blank
hard

Fill both blanks to create a dictionary of battery status for each drone.

Drone Programming
battery_status = {drone_id: [1] for drone_id in drone_list if battery_levels[drone_id] [2] warning_threshold}
Drag options to blanks, or click blank then click option'
Abattery_levels[drone_id]
B>
C<=
Ddrone_id
Attempts:
3 left
💡 Hint
Common Mistakes
Using '>' instead of '<=' includes drones with high battery.
Using 'drone_id' as value stores only IDs, not battery levels.
5fill in blank
hard

Fill all three blanks to create a failsafe report dictionary with drone ID, battery level, and status.

Drone Programming
failsafe_report = [1]: [2] for [3] in drones if drones[[3]]['battery'] < critical_threshold
Drag options to blanks, or click blank then click option'
Adrone_id
Bbattery_level
C<
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong variable name in the loop.
Using incorrect comparison operator.