Challenge - 5 Problems
Failsafe Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ Predict Output
intermediate2:00remaining
What is the output when GPS signal is lost?
Consider this drone control snippet that triggers a failsafe when GPS signal is lost. What will be printed?
Drone Programming
def check_gps(signal_strength): if signal_strength < 20: print("Failsafe activated: Returning to home.") else: print("GPS signal stable.") check_gps(15)
Attempts:
2 left
💡 Hint
Check the condition for signal strength less than 20.
✗ Incorrect
The function prints the failsafe message when signal_strength is below 20. Since 15 < 20, it prints the failsafe message.
❓ Predict Output
intermediate2:00remaining
What happens if battery level is exactly at threshold?
This code triggers a failsafe if battery is below 15%. What will it print if battery is exactly 15%?
Drone Programming
def battery_check(level): if level < 15: print("Failsafe: Land immediately.") else: print("Battery level sufficient.") battery_check(15)
Attempts:
2 left
💡 Hint
Check if the condition includes equality or only less than.
✗ Incorrect
The condition is level < 15, so 15 is not less than 15. It prints the else branch.
❓ Predict Output
advanced2:00remaining
What error occurs if failsafe function is called without parameters?
What error will this code raise when calling failsafe() without arguments?
Drone Programming
def failsafe(mode): if mode == "return": print("Returning to home.") elif mode == "land": print("Landing immediately.") else: print("Unknown mode.") failsafe()
Attempts:
2 left
💡 Hint
Check the function definition and how it is called.
✗ Incorrect
The function requires one argument 'mode'. Calling it without arguments raises a TypeError.
🧠 Conceptual
advanced2:00remaining
Which condition triggers failsafe on sensor failure?
Given a sensor reading variable 'sensor_ok' that is True when sensors work and False when they fail, which condition correctly triggers the failsafe?
Attempts:
2 left
💡 Hint
Remember the difference between assignment and comparison.
✗ Incorrect
Option B correctly compares sensor_ok to False using '=='. Option B uses assignment '=' which performs an assignment instead of a comparison. Option B also works logically but is less clear. Option B triggers failsafe when sensor is OK, which is wrong.
❓ Predict Output
expert3:00remaining
What is the output of the failsafe retry loop?
This code tries to reconnect up to 3 times. What will it print?
Drone Programming
def reconnect(): for attempt in range(1, 4): print(f"Attempt {attempt}: Trying to reconnect...") if attempt == 2: print("Reconnected successfully.") break else: print("Failed to reconnect after 3 attempts.") reconnect()
Attempts:
2 left
💡 Hint
Check how the break affects the else clause of the loop.
✗ Incorrect
The loop breaks on attempt 2 after printing success, so the else clause does not run.