📖 Scenario: You are working for a drone company that wants to organize information about different career roles in drone technology. Each role has a name and a brief description of what it involves.
🎯 Goal: You will create a dictionary to store drone career roles and their descriptions, set a filter to find roles related to a specific keyword, extract those roles using a dictionary comprehension, and finally display the filtered roles.
📋 What You'll Learn
Create a dictionary called drone_careers with exact role-description pairs
Create a variable called keyword with the exact string to filter roles
Use a dictionary comprehension to create filtered_careers with roles whose descriptions contain the keyword
Print the filtered_careers dictionary
💡 Why This Matters
🌍 Real World
Organizing and filtering career information helps companies and job seekers find relevant roles in drone technology.
💼 Career
Understanding how to manage and filter data structures is important for roles in software development and data analysis within the drone industry.
Progress0 / 4 steps
1
Create the drone careers dictionary
Create a dictionary called drone_careers with these exact entries: 'Drone Pilot': 'Operates drones for various missions', 'Drone Engineer': 'Designs and builds drone hardware', 'Data Analyst': 'Analyzes data collected by drones', 'Software Developer': 'Develops software for drone control', 'Maintenance Technician': 'Maintains and repairs drones'.
Drone Programming
Hint
Use curly braces {} to create a dictionary with the exact keys and values given.
2
Set the keyword to filter careers
Create a variable called keyword and set it to the string 'drone' (all lowercase).
Drone Programming
Hint
Assign the exact string 'drone' to the variable keyword.
3
Filter careers using dictionary comprehension
Use a dictionary comprehension to create a new dictionary called filtered_careers that includes only the roles and descriptions from drone_careers where the keyword appears in the description (case insensitive). Use for role, desc in drone_careers.items() and check if keyword is in desc.lower().
Drone Programming
Hint
Use a dictionary comprehension with for role, desc in drone_careers.items() and check if keyword is in desc.lower().
4
Display the filtered careers
Write a print statement to display the filtered_careers dictionary.
Drone Programming
Hint
Use print(filtered_careers) to show the filtered dictionary.
Practice
(1/5)
1. Which of the following is a common career opportunity related to drone programming?
easy
A. Developing software to control drone flight paths
B. Designing drone packaging materials
C. Selling drone insurance policies
D. Writing drone user manuals
Solution
Step 1: Understand drone programming roles
Drone programming involves creating software that controls drones, such as flight paths and sensors.
Step 2: Identify the option related to programming
Developing software to control drone flight paths describes developing software for drone flight, which matches drone programming.
Final Answer:
Developing software to control drone flight paths -> Option A
Quick Check:
Drone programming = software development [OK]
Hint: Look for software-related tasks in drone careers [OK]
Common Mistakes:
Confusing hardware roles with programming
Choosing options unrelated to software
Ignoring the programming focus
2. Which of these is the correct syntax to define a function in a drone programming script using Python?
easy
A. function flyDrone():
B. define flyDrone()
C. func flyDrone()
D. def flyDrone():
Solution
Step 1: Recall Python function syntax
In Python, functions are defined using the keyword def followed by the function name and parentheses.
Step 2: Match options to Python syntax
def flyDrone(): uses def flyDrone():, which is correct Python syntax.
Final Answer:
def flyDrone(): -> Option D
Quick Check:
Python function = def [OK]
Hint: Python functions start with 'def' keyword [OK]
Common Mistakes:
Using 'function' like JavaScript
Using 'func' or 'define' which are invalid in Python
Missing colon at the end
3. What will be the output of this Python code snippet used in drone programming?
commands = ['takeoff', 'forward', 'left', 'land']
for i, cmd in enumerate(commands):
print(f"Step {i+1}: {cmd}")
medium
A. Step 1: takeoff\nStep 2: forward\nStep 3: left\nStep 4: land
B. Step 0: takeoff\nStep 1: forward\nStep 2: left\nStep 3: land
C. Step 1: takeoff\nStep 2: forward\nStep 3: left
D. Error: enumerate not defined
Solution
Step 1: Understand enumerate usage
enumerate(commands) returns pairs of (index, command) starting at 0.
Step 2: Analyze print statement
Print uses i+1 for step number, so steps start at 1, printing all commands.
Final Answer:
Step 1: takeoff\nStep 2: forward\nStep 3: left\nStep 4: land -> Option A
Quick Check:
Index + 1 = step number [OK]
Hint: Remember enumerate starts at 0; add 1 for human count [OK]
Common Mistakes:
Forgetting to add 1 to index
Missing last command in output
Assuming enumerate causes error
4. Identify the error in this drone programming Python code snippet:
Python requires a colon ':' after the function header line.
Step 2: Verify other syntax elements
Function call and print statement are correct; parentheses in print are present.
Final Answer:
Missing colon ':' after function definition -> Option C
Quick Check:
Function header needs ':' [OK]
Hint: Function headers always end with ':' in Python [OK]
Common Mistakes:
Ignoring missing colon
Thinking print needs parentheses removed
Assuming indentation is wrong
5. You want to create a dictionary in Python that maps drone model names to their maximum flight time in minutes. Which code correctly creates this dictionary for models 'Alpha' (30 min), 'Beta' (45 min), and 'Gamma' (25 min)?