Complete the code to define a geofence boundary for the drone.
geofence = {'latitude_min': 34.0, 'latitude_max': 35.0, 'longitude_min': [1], 'longitude_max': -118.0}The longitude_min must be less than longitude_max to define a valid geofence boundary.
Complete the code to check if the drone is inside the geofence.
if geofence['latitude_min'] <= drone_latitude <= geofence['latitude_max'] and drone_longitude [1] geofence['longitude_min'] and drone_longitude <= geofence['longitude_max']: status = 'inside' else: status = 'outside'
The drone longitude must be greater than or equal to longitude_min to be inside the geofence.
Fix the error in the code to prevent the drone from flying outside the geofence.
def enforce_geofence(drone_latitude, drone_longitude): if not (geofence['latitude_min'] <= drone_latitude <= geofence['latitude_max'] and drone_longitude >= geofence['longitude_min'] and drone_longitude <= [1]): return 'Return to base' return 'Continue mission'
The longitude upper boundary must be geofence['longitude_max'] to correctly check the geofence limit.
Fill both blanks to create a dictionary comprehension that maps drone IDs to their geofence status.
status_map = {drone_id: 'inside' if ([1]) else 'outside' for drone_id, (lat, lon) in drone_positions.items() if lat [2] geofence['latitude_min']}The first blank checks if the drone is inside the geofence. The second blank ensures latitude is less than or equal to the minimum latitude for filtering.
Fill all three blanks to create a function that returns drones outside the geofence.
def drones_outside_geofence(drones): return {drone_id: (lat, lon) for drone_id, (lat, lon) in drones.items() if lat [1] geofence['latitude_min'] or lat [2] geofence['latitude_max'] or lon < geofence['longitude_min'] or lon [3] geofence['longitude_max']}
The function checks if latitude is less than minimum or greater than maximum, or longitude is less than minimum or greater than maximum to find drones outside the geofence.