0
0
Drone Programmingprogramming~10 mins

Swarm simulation frameworks 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 initialize the swarm simulation environment.

Drone Programming
swarm = SwarmSimulation([1]=10)
Drag options to blanks, or click blank then click option'
Anum_drones
Bspeed
Caltitude
Dbattery_life
Attempts:
3 left
💡 Hint
Common Mistakes
Using speed or altitude instead of the number of drones.
2fill in blank
medium

Complete the code to set the communication range for drones in the swarm.

Drone Programming
swarm.set_communication_range([1])
Drag options to blanks, or click blank then click option'
A500
Brange
C1000
Dsignal_strength
Attempts:
3 left
💡 Hint
Common Mistakes
Passing variable names instead of numeric values.
3fill in blank
hard

Fix the error in the code to update drone positions in the simulation loop.

Drone Programming
for drone in swarm.drones:
    drone.update_position([1])
Drag options to blanks, or click blank then click option'
Aposition
Bvelocity_vector
Cspeed
Ddirection
Attempts:
3 left
💡 Hint
Common Mistakes
Passing only speed or direction separately instead of a vector.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps drone IDs to their battery levels if battery is above 20%.

Drone Programming
battery_status = {drone.[1]: drone.[2] for drone in swarm.drones if drone.battery > 20}
Drag options to blanks, or click blank then click option'
Aid
Bbattery
Cposition
Dstatus
Attempts:
3 left
💡 Hint
Common Mistakes
Using position or status instead of id or battery.
5fill in blank
hard

Fill all three blanks to filter drones with speed greater than 5 and create a dictionary of their IDs and current positions.

Drone Programming
fast_drones = {drone.[1]: drone.[2] for drone in swarm.drones if drone.[3] > 5}
Drag options to blanks, or click blank then click option'
Aid
Bposition
Cspeed
Dbattery
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up battery with speed or position.