📖 Scenario: You are programming a drone to inspect a set of infrastructure points such as bridges, towers, and pipelines. The drone needs to check each point's status and decide if it requires maintenance based on a damage score.
🎯 Goal: Build a simple program that stores infrastructure points with their damage scores, sets a damage threshold, filters points that need maintenance, and prints the list of points requiring maintenance.
📋 What You'll Learn
Create a dictionary with infrastructure points and their damage scores
Set a damage threshold value
Use a loop or comprehension to find points needing maintenance
Print the list of points that require maintenance
💡 Why This Matters
🌍 Real World
Drones inspecting infrastructure help find problems early to keep bridges, towers, and pipelines safe.
💼 Career
This project shows how to process sensor data and make decisions, skills useful for drone programming and maintenance automation jobs.
Progress0 / 4 steps
1
Create infrastructure data
Create a dictionary called infrastructure with these exact entries: 'Bridge A': 3, 'Tower B': 7, 'Pipeline C': 5, 'Bridge D': 2, 'Tower E': 8
Drone Programming
Hint
Use curly braces {} to create a dictionary with keys as point names and values as damage scores.
2
Set damage threshold
Create a variable called damage_threshold and set it to 5
Drone Programming
Hint
Just assign the number 5 to the variable damage_threshold.
3
Find points needing maintenance
Create a list called needs_maintenance that contains the names of points from infrastructure where the damage score is greater than damage_threshold. Use a list comprehension with point and score as variables in for point, score in infrastructure.items()
Drone Programming
Hint
Use a list comprehension to check each score and include the point if the score is greater than damage_threshold.
4
Print points needing maintenance
Write a print statement to display the list needs_maintenance
Drone Programming
Hint
Use print(needs_maintenance) to show the points that need maintenance.
Practice
(1/5)
1. What is the main purpose of using a drone's inspect() function in infrastructure inspection?
easy
A. To control the drone's speed during flight
B. To repair damaged parts of the infrastructure
C. To send the drone to a specific location for inspection
D. To charge the drone's battery automatically
Solution
Step 1: Understand the function purpose
The inspect() function is designed to send the drone to a location for inspection.
Step 2: Compare options with function role
Only To send the drone to a specific location for inspection matches the purpose of sending the drone to inspect infrastructure.
Final Answer:
To send the drone to a specific location for inspection -> Option C
Quick Check:
inspect() sends drone to location = A [OK]
Hint: Remember: inspect() means 'go check there' [OK]
Common Mistakes:
Confusing inspect() with repair functions
Thinking inspect() controls speed
Assuming inspect() charges battery
2. Which of the following is the correct syntax to capture an image during a drone inspection?
easy
A. drone.captureImage()
B. drone.capture-Image()
C. drone.captureimage()
D. drone.capture_image()
Solution
Step 1: Identify correct method naming style
In drone programming, method names use lowercase with underscores for readability.
Step 2: Match options to correct style
drone.capture_image() uses capture_image(), which is the correct syntax.
Final Answer:
drone.capture_image() -> Option D
Quick Check:
Method names use underscores = D [OK]
Hint: Use underscores for multi-word method names [OK]