Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a supervisor agent that manages tasks.
Agentic AI
class SupervisorAgent: def __init__(self): self.tasks = [] def add_task(self, task): self.tasks.[1](task)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using remove instead of append will cause an error because the task is not yet in the list.
Using pop removes an item, which is not what we want here.
✗ Incorrect
The supervisor agent adds tasks to its list using the append method.
2fill in blank
mediumComplete the code to have the supervisor agent execute all tasks.
Agentic AI
class SupervisorAgent: def __init__(self): self.tasks = [] def execute_all(self): for task in self.tasks: task.[1]()
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using run or start may not match the task's method name.
Using perform is uncommon and may cause an AttributeError.
✗ Incorrect
The supervisor calls the execute method on each task to run it.
3fill in blank
hardFix the error in the supervisor agent's task removal method.
Agentic AI
class SupervisorAgent: def __init__(self): self.tasks = [] def remove_task(self, task): if task in self.tasks: self.tasks.[1](task) else: print("Task not found")
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using delete causes a syntax error.
Using pop requires an index, not a value.
✗ Incorrect
The remove method deletes the first matching element from the list.
4fill in blank
hardFill both blanks to create a dictionary of task statuses.
Agentic AI
task_status = {task.[1]: task.[2] for task in supervisor.tasks} Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using result instead of status may not reflect the current task state.
Using id as key is possible but name is more readable.
✗ Incorrect
We use task.name as the key and task.status as the value to track each task's status.
5fill in blank
hardFill all three blanks to filter and collect completed tasks.
Agentic AI
completed_tasks = [task for task in supervisor.tasks if task.[1] == [2]] completed_names = [task.[3] for task in completed_tasks]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using result instead of name for collecting task identifiers.
Comparing status to a wrong string value.
✗ Incorrect
We check if task.status equals 'completed' and collect their names.