Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to define a single agent that takes an action.
Agentic AI
class Agent: def act(self, state): return [1]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Returning the state instead of an action.
Returning None or self which are not valid actions.
✗ Incorrect
The agent's act method should return an action, here the string 'move_forward'.
2fill in blank
mediumComplete the code to initialize a multi-agent system with two agents.
Agentic AI
class MultiAgentSystem: def __init__(self): self.agents = [[1], Agent()]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using the class name without parentheses.
Using undefined variables.
✗ Incorrect
We need to create instances of Agent using Agent() to add to the list.
3fill in blank
hardFix the error in the method that collects actions from all agents.
Agentic AI
def get_actions(self, state): return [agent.[1](state) for agent in self.agents]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using method names that do not exist like 'move' or 'run'.
✗ Incorrect
The method to get an agent's action is called act.
4fill in blank
hardFill both blanks to create a dictionary of agent actions keyed by agent id.
Agentic AI
def actions_dict(self, state): return {agent.[1]: agent.[2](state) for agent in self.agents}
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using
name instead of id.Using
state instead of calling act.✗ Incorrect
Use agent.id as the key and agent.act(state) as the value.
5fill in blank
hardFill all three blanks to implement a step where all agents act and results are collected.
Agentic AI
def step(self, state): results = {agent.[1]: agent.[2](state) for agent in self.agents} return results if results else [3]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Returning None instead of an empty dictionary.
Using wrong attribute or method names.
✗ Incorrect
Use agent.id as keys, agent.act(state) as values, and return an empty dictionary if no results.