Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a simple agent that prints a greeting.
Agentic AI
class SimpleAgent: def __init__(self, name): self.name = name def greet(self): print([1])
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting to use self.name inside the method.
Trying to print a string without concatenating the name.
✗ Incorrect
The greet method should print a greeting that includes the agent's name, so concatenating the string with self.name is correct.
2fill in blank
mediumComplete the code to make the agent decide an action based on input.
Agentic AI
def decide_action(input_text): if 'hello' in input_text.lower(): return [1] else: return 'ignore'
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Returning a variable name without quotes.
Returning a wrong string that does not match the expected action.
✗ Incorrect
The function should return the string 'respond' when 'hello' is in the input text.
3fill in blank
hardFix the error in the agent's learning method to update knowledge correctly.
Agentic AI
class LearningAgent: def __init__(self): self.knowledge = [] def learn(self, data): self.knowledge.[1](data)
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using extend which expects an iterable and causes error if data is not iterable.
Using add which is not a list method.
✗ Incorrect
To add a single data item to the knowledge list, append is the correct method.
4fill in blank
hardFill both blanks to create a dictionary of agent names and their scores above 50.
Agentic AI
scores = {'agent1': 45, 'agent2': 75, 'agent3': 60}
high_scores = { [1]: [2] for [1], [2] in scores.items() if [2] > 50 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Not matching the variable names in the comprehension.
✗ Incorrect
The dictionary comprehension uses 'name' as the key variable and 'score' as the value from scores[name].
5fill in blank
hardFill all three blanks to filter and transform agent data into a new dictionary.
Agentic AI
agents = {'a1': 30, 'a2': 55, 'a3': 70}
filtered_agents = { [1]: [2]*2 for [1] in agents if agents[[3]] > 50 } Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using different variable names inconsistently.
Not multiplying the value correctly.
✗ Incorrect
The comprehension uses 'agent_id' as the key, doubles the value agents[agent_id], and filters by agents[agent_id] > 50.
