0
0
Drone Programmingprogramming~10 mins

Why geofencing is required in Drone Programming - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to define a geofence boundary for the drone.

Drone Programming
geofence = {'latitude_min': 34.0, 'latitude_max': 35.0, 'longitude_min': [1], 'longitude_max': -118.0}
Drag options to blanks, or click blank then click option'
A-119.0
B-120.0
C-116.0
D-117.0
Attempts:
3 left
💡 Hint
Common Mistakes
Using a longitude_min greater than longitude_max causing invalid geofence.
2fill in blank
medium

Complete the code to check if the drone is inside the geofence.

Drone Programming
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'
Drag options to blanks, or click blank then click option'
A<=
B>=
C>
D<
Attempts:
3 left
💡 Hint
Common Mistakes
Using '<' instead of '>=' causing incorrect boundary check.
3fill in blank
hard

Fix the error in the code to prevent the drone from flying outside the geofence.

Drone Programming
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'
Drag options to blanks, or click blank then click option'
Ageofence['longitude_min']
Bgeofence['latitude_max']
Cgeofence['latitude_min']
Dgeofence['longitude_max']
Attempts:
3 left
💡 Hint
Common Mistakes
Using latitude values instead of longitude for longitude boundary check.
4fill in blank
hard

Fill both blanks to create a dictionary comprehension that maps drone IDs to their geofence status.

Drone Programming
status_map = {drone_id: 'inside' if ([1]) else 'outside' for drone_id, (lat, lon) in drone_positions.items() if lat [2] geofence['latitude_min']}
Drag options to blanks, or click blank then click option'
Ageofence['latitude_min'] <= lat <= geofence['latitude_max'] and geofence['longitude_min'] <= lon <= geofence['longitude_max']
Blat > geofence['latitude_max']
C<=
D>
Attempts:
3 left
💡 Hint
Common Mistakes
Using incorrect comparison operators causing wrong filtering or status assignment.
5fill in blank
hard

Fill all three blanks to create a function that returns drones outside the geofence.

Drone Programming
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']}
Drag options to blanks, or click blank then click option'
A<
B>
D<=
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong comparison operators causing incorrect detection of outside drones.