Bird
0
0

Consider this simple agent code snippet:

medium📝 Predict Output Q13 of 15
Agentic AI - Future of AI Agents
Consider this simple agent code snippet:
class Agent:
    def __init__(self):
        self.state = 0
    def perceive(self, input):
        self.state += input
    def act(self):
        return self.state * 2

agent = Agent()
agent.perceive(3)
agent.perceive(2)
output = agent.act()

What is the value of output after running this code?
A10
B0
C6
D5
Step-by-Step Solution
Solution:
  1. Step 1: Track the agent's state changes

    Initially, state = 0. After perceive(3), state = 3. After perceive(2), state = 5.
  2. Step 2: Calculate the action output

    act() returns state * 2 = 5 * 2 = 10.
  3. Final Answer:

    10 -> Option A
  4. Quick Check:

    State sum 5 * 2 = 10 [OK]
Quick Trick: Sum inputs before doubling output [OK]
Common Mistakes:
  • Using only last input instead of sum
  • Forgetting to multiply by 2
  • Confusing initial state as output

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes