0
0
Drone Programmingprogramming~20 mins

Command acknowledgment handling in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Command Acknowledgment Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of acknowledgment status check
What is the output of this drone command acknowledgment code snippet?
Drone Programming
ack = {'cmd_id': 101, 'status': 'SUCCESS'}
if ack['status'] == 'SUCCESS':
    print(f"Command {ack['cmd_id']} executed successfully.")
else:
    print(f"Command {ack['cmd_id']} failed.")
ASyntaxError
BCommand 101 failed.
CKeyError
DCommand 101 executed successfully.
Attempts:
2 left
💡 Hint
Check the value of the 'status' key in the acknowledgment dictionary.
🧠 Conceptual
intermediate
1:30remaining
Understanding acknowledgment timeout handling
In drone command acknowledgment handling, what is the main purpose of implementing a timeout mechanism?
ATo stop waiting for acknowledgment after a set time and handle failure
BTo speed up the drone's flight path
CTo retry sending the command indefinitely until acknowledged
DTo log all commands regardless of acknowledgment
Attempts:
2 left
💡 Hint
Think about what happens if the drone never sends back an acknowledgment.
🔧 Debug
advanced
2:00remaining
Identify the error in acknowledgment parsing
What error will this code raise when processing the acknowledgment?
Drone Programming
ack = {'cmd_id': 202, 'status': 'FAILURE'}
print(f"Command {ack['command_id']} status: {ack['status']}")
AKeyError
BTypeError
CSyntaxError
DNo error, prints 'Command 202 status: FAILURE'
Attempts:
2 left
💡 Hint
Check the dictionary keys carefully.
📝 Syntax
advanced
1:30remaining
Syntax error in acknowledgment conditional
Which option fixes the syntax error in this acknowledgment check code?
Drone Programming
if ack['status'] = 'SUCCESS':
    print('Command succeeded')
else:
    print('Command failed')
A
if ack['status'] == 'SUCCESS'
    print('Command succeeded')
else:
    print('Command failed')
B
if ack['status'] := 'SUCCESS':
    print('Command succeeded')
else:
    print('Command failed')
C
if ack['status'] == 'SUCCESS':
    print('Command succeeded')
else:
    print('Command failed')
D
if ack['status'] = 'SUCCESS'
    print('Command succeeded')
else:
    print('Command failed')
Attempts:
2 left
💡 Hint
Remember the difference between assignment and comparison operators.
🚀 Application
expert
2:30remaining
Result of acknowledgment retry logic
Given this retry logic for command acknowledgment, what is the final value of 'attempts' after the loop ends?
Drone Programming
attempts = 0
max_attempts = 3
acknowledged = False
while attempts < max_attempts and not acknowledged:
    attempts += 1
    # Simulate acknowledgment received only on 3rd attempt
    if attempts == 3:
        acknowledged = True
print(attempts)
A2
B3
C4
D0
Attempts:
2 left
💡 Hint
Count how many times the loop runs until acknowledgment is True.