Bird
0
0

Given the code below, what will be the output?

medium📝 Predict Output Q13 of 15
Agentic AI - Production Agent Architecture
Given the code below, what will be the output?
class Agent:
    def receive(self, message):
        return f"Received: {message}"

def send_message(agent, message):
    return agent.receive(message)

agent = Agent()
print(send_message(agent, "Hello"))
AError: method not found
BHello
Csend_message(agent, Hello)
DReceived: Hello
Step-by-Step Solution
Solution:
  1. Step 1: Understand the Agent class and receive method

    The receive method returns the string 'Received: ' plus the message passed.
  2. Step 2: Trace the send_message call

    send_message calls agent.receive with "Hello", so it returns 'Received: Hello'.
  3. Final Answer:

    Received: Hello -> Option D
  4. Quick Check:

    agent.receive("Hello") = "Received: Hello" [OK]
Quick Trick: Agent.receive returns 'Received: ' plus message [OK]
Common Mistakes:
  • Expecting just the message without prefix
  • Thinking send_message prints instead of returns
  • Assuming method does not exist causing error

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Agentic AI Quizzes