📖 Scenario: You are building a simple program to check if a drone flight plan follows the Indian DGCA (Directorate General of Civil Aviation) drone regulations. The DGCA has rules about drone weight, maximum altitude, and no-fly zones.This program will help drone operators quickly verify if their drone flight plan is allowed under the rules.
🎯 Goal: Create a program that stores drone flight details, sets regulation limits, checks if the flight plan follows the DGCA rules, and then outputs whether the flight is allowed or not.
📋 What You'll Learn
Create a dictionary with drone flight details: weight in kg, altitude in meters, and location coordinates (latitude and longitude).
Create variables for DGCA regulation limits: maximum allowed weight, maximum allowed altitude, and a list of no-fly zone coordinates.
Write code to check if the drone's weight and altitude are within limits and if the location is outside all no-fly zones.
Print the final result: 'Flight Allowed' or 'Flight Not Allowed' based on the checks.
💡 Why This Matters
🌍 Real World
Drone operators in India must follow DGCA rules to fly drones safely and legally. This program helps quickly check if a flight plan is allowed.
💼 Career
Understanding how to apply regulations in code is useful for drone software developers, aviation safety engineers, and regulatory compliance specialists.
Progress0 / 4 steps
1
DATA SETUP: Create the drone flight details dictionary
Create a dictionary called drone_flight with these exact entries: 'weight_kg': 2.5, 'altitude_m': 120, 'location': (28.6139, 77.2090) (latitude and longitude of New Delhi).
Drone Programming
Hint
Use curly braces {} to create a dictionary. The location is a tuple with latitude and longitude.
2
CONFIGURATION: Set DGCA regulation limits
Create three variables: max_weight_kg set to 5, max_altitude_m set to 120, and no_fly_zones set to a list containing one tuple (28.6139, 77.2090) representing a no-fly zone at New Delhi.
Drone Programming
Hint
Use a list with one tuple for no_fly_zones. Variables are simple assignments.
3
CORE LOGIC: Check if the flight plan follows DGCA rules
Write code to check if drone_flight['weight_kg'] is less than or equal to max_weight_kg, drone_flight['altitude_m'] is less than or equal to max_altitude_m, and drone_flight['location'] is NOT in no_fly_zones. Store the result (True or False) in a variable called flight_allowed.
Drone Programming
Hint
Use the and operator to combine all conditions. Use not in to check location.
4
OUTPUT: Print if the flight is allowed or not
Write a print statement that outputs 'Flight Allowed' if flight_allowed is True, otherwise print 'Flight Not Allowed'.
Drone Programming
Hint
Use an if-else statement to print the correct message based on flight_allowed.
Practice
(1/5)
1. Which of the following is a mandatory requirement for flying a drone in India according to DGCA rules?
easy
A. Flying in restricted no-fly zones
B. Flying above 400 feet without permission
C. Registering the drone before flight
D. Ignoring the drone weight limits
Solution
Step 1: Understand DGCA registration rule
DGCA mandates that all drones must be registered before flying in India.
Step 2: Check other options against DGCA rules
Flying above 400 feet or in no-fly zones is prohibited without permission, and ignoring weight limits is not allowed.
Final Answer:
Registering the drone before flight -> Option C
Quick Check:
Registration is mandatory = C [OK]
Hint: Remember: Registration is the first step before flying [OK]
Common Mistakes:
Assuming flying above 400 feet is allowed
Ignoring no-fly zone restrictions
Thinking weight limits don't matter
2. Which Python code snippet correctly checks if a drone's altitude is within the DGCA allowed limit of 400 feet?
easy
A. if altitude <= 400:
print('Safe to fly')
B. if altitude < 400:
print('Safe to fly')
C. if altitude >= 400:
print('Safe to fly')
D. if altitude > 400:
print('Safe to fly')
Solution
Step 1: Understand altitude limit condition
DGCA allows flying up to 400 feet inclusive, so altitude <= 400 is correct.
Step 2: Analyze each condition
if altitude <= 400:
print('Safe to fly') uses <= 400, which includes 400 feet. if altitude < 400:
print('Safe to fly') excludes 400 feet, the other options allow unsafe altitudes.
Final Answer:
if altitude <= 400:\n print('Safe to fly') -> Option A
Quick Check:
Altitude must be at most 400 = B [OK]
Hint: Use <= 400 to include max allowed altitude [OK]
Common Mistakes:
Using < 400 excludes exactly 400 feet
Using >= or > allows unsafe altitudes
Confusing comparison operators
3. What will be the output of this Python code snippet checking drone weight compliance?
weight = 2.5 # in kg
if weight <= 2:
print('Light drone')
elif weight <= 25:
print('Medium drone')
else:
print('Heavy drone')
medium
A. Light drone
B. Medium drone
C. Heavy drone
D. No output
Solution
Step 1: Check weight against conditions
Weight is 2.5 kg, which is not <= 2 but is <= 25.
Step 2: Determine which print executes
Since 2.5 <= 25, the 'Medium drone' print statement runs.
Final Answer:
Medium drone -> Option B
Quick Check:
2.5 kg fits medium drone category = A [OK]
Hint: Check conditions top to bottom; first true runs [OK]
Common Mistakes:
Assuming 2.5 kg is light drone
Ignoring elif condition
Thinking else runs for 2.5 kg
4. Identify the error in this Python code snippet that checks if a drone is flying in a no-fly zone:
no_fly_zones = ['airport', 'military_base']
drone_location = 'airport'
if drone_location = no_fly_zones:
print('Drone in no-fly zone!')
medium
A. Using '=' instead of '==' in the if condition
B. Incorrect list syntax for no_fly_zones
C. Missing colon ':' after if statement
D. Wrong variable name drone_location
Solution
Step 1: Check the if condition syntax
The code uses '=' which is assignment, not comparison. It should be '==' or 'in'.
Step 2: Understand correct membership check
To check if drone_location is in no_fly_zones, use 'if drone_location in no_fly_zones:'. Using '=' causes syntax error.
Final Answer:
Using '=' instead of '==' in the if condition -> Option A
Quick Check:
Use '==' or 'in' for comparison, not '=' [OK]
Hint: Use '==' or 'in' for comparisons, '=' is assignment [OK]
Common Mistakes:
Using '=' instead of '==' or 'in'
Confusing assignment with comparison
Not checking membership properly
5. You want to write a Python function to check if a drone flight is legal under DGCA rules. The drone must be registered, fly below 400 feet, and not be in a no-fly zone. Which function correctly implements these checks?
hard
A. def is_legal(registered, altitude, location):
if registered and altitude > 400 and location not in ['airport', 'military_base']:
return True
return False
B. def is_legal(registered, altitude, location):
if registered or altitude < 400 or location in ['airport', 'military_base']:
return True
return False
C. def is_legal(registered, altitude, location):
if not registered and altitude > 400 and location in ['airport', 'military_base']:
return True
return False
D. def is_legal(registered, altitude, location):
if registered and altitude <= 400 and location not in ['airport', 'military_base']:
return True
return False
Solution
Step 1: Analyze legal conditions
Drone must be registered, altitude <= 400, and location not in no-fly zones.
Step 2: Check each option's logic
def is_legal(registered, altitude, location):
if registered and altitude <= 400 and location not in ['airport', 'military_base']:
return True
return False uses 'and' for all conditions correctly. Others use 'or' or wrong comparisons allowing illegal flights.
Final Answer:
def is_legal(registered, altitude, location):\n if registered and altitude <= 400 and location not in ['airport', 'military_base']:\n return True\n return False -> Option D
Quick Check:
All conditions must be true = A [OK]
Hint: Use 'and' to combine all legal conditions [OK]
Common Mistakes:
Using 'or' instead of 'and' allowing illegal flights
Wrong altitude comparison signs
Incorrect no-fly zone membership check
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.