Bird
0
0

What will be the output of this agent decision code?

medium📝 Predict Output Q5 of 15
Agentic AI - Future of AI Agents
What will be the output of this agent decision code? class Agent: def __init__(self): self.energy = 5 def decide(self): if self.energy > 3: return 'explore' else: return 'rest' agent = Agent() print(agent.decide()) agent.energy = 2 print(agent.decide())
Arest explore
Bexplore explore
Cexplore rest
Drest rest
Step-by-Step Solution
Solution:
  1. Step 1: Evaluate first decision

    Initial energy is 5, which is greater than 3, so decide() returns 'explore'.
  2. Step 2: Evaluate second decision

    Energy is set to 2, less than or equal to 3, so decide() returns 'rest'.
  3. Final Answer:

    explore rest -> Option C
  4. Quick Check:

    Energy check controls decision [OK]
Quick Trick: Decision depends on energy threshold > 3 [OK]
Common Mistakes:
  • Mixing up energy comparison operators
  • Not updating energy before second decision
  • Assuming decisions are random

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes