Complete the code to create a list of agents.
agents = [[1] for _ in range(5)]
The code creates 5 new Agent objects in a list using a list comprehension.
Complete the code to have each agent perform a task.
for agent in agents: agent.[1]()
The method perform_task() is called on each agent to make it do its job.
Fix the error in the code to collect results from agents.
results = [agent.[1] for agent in agents]
The method get_result() must be called with parentheses to get each agent's output.
Fill both blanks to combine agent results and check if all succeeded.
combined = sum(results) all_success = all(result [1] [2] 0 for result in results)
We check if all results are greater than or equal to zero to confirm success.
Fill all three blanks to create a dictionary mapping agent IDs to their results if result is positive.
agent_results = {agent.id: result for agent, result in zip(agents, results) if result [1] [2] 0 and agent.[3]The dictionary comprehension filters results greater than zero and only includes agents that are active.
