Complete the code to check if two drones are too close.
if distance(drone1.position, drone2.position) [1] safe_distance: avoid_collision()
We check if the distance is less than the safe distance to avoid collisions.
Complete the code to update drone velocity to avoid collision.
if distance(drone.position, neighbor.position) < safe_distance: drone.velocity = drone.velocity [1] avoid_vector
We subtract the avoid vector to steer the drone away from neighbors.
Fix the error in the collision check condition.
if distance(drone.position, neighbor.position) [1] safe_distance: slow_down()
The operator '<=' correctly checks if the distance is less than or equal to the safe distance.
Fill both blanks to create a dictionary of drones with their speeds above threshold.
fast_drones = {drone.id: drone.[1] for drone in swarm if drone.[2] > speed_threshold}We use 'speed' to get the drone's speed and filter drones with speed above the threshold.
Fill all three blanks to filter drones and create a dictionary with adjusted speeds.
adjusted_speeds = {drone.[1]: drone.[2] * speed_factor for drone in swarm if drone.[3] < max_speed}We use 'id' as the key, multiply 'speed' by a factor, and filter drones with speed less than max_speed.