0
0
Drone Programmingprogramming~20 mins

Swarm simulation frameworks in Drone Programming - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Swarm Simulation Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
Predict Output
intermediate
2:00remaining
Output of a simple swarm position update
What is the output of this code that updates drone positions in a swarm simulation?
Drone Programming
positions = [(0,0), (1,1), (2,2)]
velocities = [(1,0), (0,1), (-1,-1)]
new_positions = [(x+vx, y+vy) for (x,y), (vx,vy) in zip(positions, velocities)]
print(new_positions)
A[(1, 0), (2, 2), (1, 1)]
B[(1, 0), (1, 2), (1, 1)]
C[(1, 0), (1, 2), (3, 3)]
D[(0, 0), (1, 1), (2, 2)]
Attempts:
2 left
💡 Hint
Think about adding each velocity component to the corresponding position.
🧠 Conceptual
intermediate
1:30remaining
Key feature of swarm simulation frameworks
Which feature is essential for a swarm simulation framework to handle large numbers of drones efficiently?
ADistributed communication and local decision-making
BCentralized control of all drones from one point
CManual control of each drone by a human operator
DRendering 3D graphics for each drone individually
Attempts:
2 left
💡 Hint
Think about how real swarms work without a single leader.
🔧 Debug
advanced
2:30remaining
Identify the error in this drone collision avoidance code
What error does this code produce when running a drone collision avoidance step? positions = [(0,0), (1,1), (2,2)] for i, pos in enumerate(positions): for j, other_pos in enumerate(positions): if i != j and abs(pos[0] - other_pos[0]) < 1 and abs(pos[1] - other_pos[1]) < 1: positions[i] = (pos[0]+1, pos[1]+1) print(positions)
ARuntimeError due to modifying list during iteration
BIndexError because of invalid index access
CTypeError due to wrong data type in positions
DPositions updated correctly without error
Attempts:
2 left
💡 Hint
Check if modifying list elements during iteration is allowed in Python.
📝 Syntax
advanced
1:30remaining
Syntax error in drone command sequence
Which option contains a syntax error in this drone command sequence code?
Drone Programming
commands = ['takeoff', 'move_forward', 'land']
for cmd in commands
    print(f"Executing {cmd}")
A
for cmd in commands:
    print(f"Executing {cmd}")
B
for cmd in commands:
    print("Executing " + cmd)
C
for cmd in commands
    print(f"Executing {cmd}")
D
)"}dmc{ gnitucexE"f(tnirp    
:sdnammoc ni dmc rof
Attempts:
2 left
💡 Hint
Look for missing punctuation in the for loop.
🚀 Application
expert
2:00remaining
Number of drones after filtering by battery level
Given this code filtering drones with battery above 50%, how many drones remain?
Drone Programming
drones = [{'id':1, 'battery': 45}, {'id':2, 'battery': 75}, {'id':3, 'battery': 55}, {'id':4, 'battery': 30}]
active = [d for d in drones if d['battery'] > 50]
print(len(active))
A2
B3
C1
D4
Attempts:
2 left
💡 Hint
Count drones with battery strictly greater than 50.