0
0
Drone Programmingprogramming~20 mins

Why geofencing is required in Drone Programming - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Geofencing Mastery
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Purpose of Geofencing in Drone Programming

Why is geofencing an important feature in drone programming?

ATo increase the drone's battery life by optimizing flight speed automatically.
BTo prevent drones from flying into restricted or dangerous areas by setting virtual boundaries.
CTo allow drones to communicate with other drones in the air for formation flying.
DTo enable drones to capture higher resolution images by adjusting camera settings.
Attempts:
2 left
💡 Hint

Think about safety and legal restrictions when flying drones.

Predict Output
intermediate
2:00remaining
Output of Geofence Boundary Check Function

What is the output of this Python function that checks if a drone is inside a geofence?

Drone Programming
def is_inside_geofence(x, y, fence):
    # fence is a dict with 'xmin', 'xmax', 'ymin', 'ymax'
    return fence['xmin'] <= x <= fence['xmax'] and fence['ymin'] <= y <= fence['ymax']

fence = {'xmin': 0, 'xmax': 10, 'ymin': 0, 'ymax': 10}
print(is_inside_geofence(5, 5, fence))
print(is_inside_geofence(15, 5, fence))
ATrue\nFalse
BFalse\nTrue
CTrue\nTrue
DFalse\nFalse
Attempts:
2 left
💡 Hint

Check if the point (x,y) lies within the rectangle defined by fence boundaries.

🔧 Debug
advanced
2:00remaining
Identify the Error in Geofence Violation Alert Code

What error will this code produce when checking geofence violation?

Drone Programming
def alert_violation(position, fence):
    if position['x'] < fence['xmin'] or position['x'] > fence['xmax'] or position['y'] < fence['ymin'] or position['y'] > fence['ymax']:
        print("Warning: Geofence violated!")

alert_violation({'x': 12, 'y': 5}, {'xmin': 0, 'xmax': 10, 'ymin': 0, 'ymax': 10})
ASyntaxError due to missing colon after if statement
BKeyError because 'x' key is missing in position dictionary
CTypeError because position is not a dictionary
DNo error, prints warning correctly
Attempts:
2 left
💡 Hint

Check the syntax of the if statement carefully.

📝 Syntax
advanced
2:00remaining
Correct Syntax for Defining a Geofence Polygon

Which option correctly defines a geofence polygon as a list of coordinate tuples in Python?

Ageofence = [(0,0); (10,0); (10,10); (0,10)]
Bgeofence = {(0,0), (10,0), (10,10), (0,10)}
Cgeofence = [(0,0), (10,0), (10,10), (0,10]
Dgeofence = [(0,0), (10,0), (10,10), (0,10)]
Attempts:
2 left
💡 Hint

Remember how lists and tuples are defined in Python.

🚀 Application
expert
2:00remaining
Number of Geofence Violations Detected

Given this code that tracks drone positions and counts geofence violations, what is the final value of violations?

Drone Programming
fence = {'xmin': 0, 'xmax': 10, 'ymin': 0, 'ymax': 10}
positions = [{'x': 5, 'y': 5}, {'x': 11, 'y': 5}, {'x': 7, 'y': 12}, {'x': 3, 'y': 3}]
violations = 0
for pos in positions:
    if pos['x'] < fence['xmin'] or pos['x'] > fence['xmax'] or pos['y'] < fence['ymin'] or pos['y'] > fence['ymax']:
        violations += 1
print(violations)
A0
B1
C2
D3
Attempts:
2 left
💡 Hint

Count how many positions fall outside the fence boundaries.