0
0
Agentic AIml~10 mins

Why memory makes agents useful in Agentic AI - Test Your Understanding

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create an agent that remembers past inputs.

Agentic AI
class Agent:
    def __init__(self):
        self.memory = [1]

agent = Agent()
Drag options to blanks, or click blank then click option'
A[]
B{}
CNone
D0
Attempts:
3 left
💡 Hint
Common Mistakes
Using None or 0 which cannot store multiple past inputs.
Using a dictionary which is unordered for this simple memory.
2fill in blank
medium

Complete the code to add a new input to the agent's memory.

Agentic AI
class Agent:
    def __init__(self):
        self.memory = []
    def remember(self, input):
        self.memory.[1](input)

agent = Agent()
agent.remember('hello')
Drag options to blanks, or click blank then click option'
Aextend
Bappend
Cinsert
Dadd
Attempts:
3 left
💡 Hint
Common Mistakes
Using add() which is for sets, not lists.
Using extend() which expects an iterable, not a single item.
3fill in blank
hard

Fix the error in the code that retrieves the last remembered input.

Agentic AI
class Agent:
    def __init__(self):
        self.memory = []
    def remember(self, input):
        self.memory.append(input)
    def recall(self):
        return self.memory[1]

agent = Agent()
agent.remember('data')
last = agent.recall()
Drag options to blanks, or click blank then click option'
A[-2]
B[0]
C[-1]
D[1]
Attempts:
3 left
💡 Hint
Common Mistakes
Using [0] which returns the first item, not the last.
Using [1] which may cause errors if list has only one item.
4fill in blank
hard

Fill both blanks to create a method that clears the agent's memory and checks if memory is empty.

Agentic AI
class Agent:
    def __init__(self):
        self.memory = []
    def clear_memory(self):
        self.memory.[1]()
    def is_memory_empty(self):
        return len(self.memory) [2] 0
Drag options to blanks, or click blank then click option'
Aclear
Bappend
C==
D!=
Attempts:
3 left
💡 Hint
Common Mistakes
Using append() instead of clear() to empty the list.
Using != instead of == to check if memory is empty.
5fill in blank
hard

Fill all three blanks to create a method that returns a dictionary of memory items with their lengths, filtering only those longer than 3 characters.

Agentic AI
class Agent:
    def __init__(self):
        self.memory = []
    def memory_summary(self):
        return { [1]: [2] for item in self.memory if len(item) [3] 3 }
Drag options to blanks, or click blank then click option'
Aitem
C>
Dlen(item)
Attempts:
3 left
💡 Hint
Common Mistakes
Using list comprehension instead of dictionary comprehension.
Using < instead of > for filtering longer items.