Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to assign a task to a drone.
Drone Programming
drone.task = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to put quotes around the task name.
Using undefined variable names.
✗ Incorrect
The task name must be a string, so it needs quotes around it.
2fill in blank
mediumComplete the code to check if the drone is available for a new task.
Drone Programming
if drone.status == [1]:
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using status values without quotes.
Using incorrect status strings.
✗ Incorrect
The drone status must be compared to the string "available" to check if it can take a new task.
3fill in blank
hardFix the error in the code to add a task to the drone's task queue.
Drone Programming
drone.tasks.[1]("inspect_building")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using add() which is for sets, not lists.
Using push() which is not a Python list method.
✗ Incorrect
The correct method to add an item to a list in Python is append().
4fill in blank
hardFill both blanks to create a dictionary of tasks assigned to drones with priority filtering.
Drone Programming
assigned_tasks = {drone.id: task for drone, task in task_list if task.priority [1] 5 and drone.status == [2] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using < instead of > for priority filtering.
Using != instead of == for status check.
✗ Incorrect
We want tasks with priority greater than 5 and drones that are exactly available.
5fill in blank
hardFill all three blanks to create a dictionary comprehension that maps drone names to their current task if the task is urgent.
Drone Programming
urgent_tasks = {drone.[1]: drone.[2] for drone in drones if drone.task.[3] == True} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'status' instead of 'is_urgent' to check urgency.
Using wrong attribute names for drone or task.
✗ Incorrect
We map drone names to their current tasks only if the task is marked urgent.