Consider this drone failsafe code snippet. What will the drone do if the battery level drops below 10%?
battery_level = 9 failsafe_action = 'RTL' if battery_level < 10 else 'Land' print(failsafe_action)
Check the condition for battery level and the assigned action.
The code checks if battery_level is less than 10. Since 9 is less than 10, it sets failsafe_action to 'RTL' and prints it.
Choose the most appropriate failsafe action for a drone that loses GPS signal but is currently flying over a safe landing zone.
Think about safety and location when GPS is lost.
Landing immediately is safest when GPS is lost over a safe zone, as RTL or SmartRTL require GPS to navigate back.
Analyze the following code snippet and identify the error it will cause when executed.
def failsafe_action(signal_lost): if signal_lost == True: return 'SmartRTL' else: return 'Land' print(failsafe_action(True))
Look carefully at the if statement syntax.
The code uses '=' instead of '==' in the if condition, causing a SyntaxError.
Given the drone's altitude and GPS status, what will the failsafe function return?
def decide_failsafe(gps_signal, altitude): if not gps_signal and altitude > 20: return 'Land' elif gps_signal and altitude > 20: return 'SmartRTL' else: return 'RTL' print(decide_failsafe(True, 25))
Check the conditions in order and the values passed.
GPS is True and altitude is 25 (>20), so the function returns 'SmartRTL'.
Given this sequence of drone events, how many times will the failsafe action be triggered?
events = [
{'battery': 15, 'gps': True},
{'battery': 9, 'gps': True},
{'battery': 8, 'gps': False},
{'battery': 5, 'gps': False},
{'battery': 12, 'gps': True}
]
failsafe_count = 0
for event in events:
if event['battery'] < 10 or not event['gps']:
failsafe_count += 1
print(failsafe_count)Count events where battery is below 10 or GPS is lost.
Events 2, 3, and 4 trigger failsafe (battery < 10 or gps False), so count is 3.