2. Which of the following is the correct way to import a framework module for agent development in Python?
easy
A. import agent_framework
B. include agent_framework
C. using agent_framework
D. require('agent_framework')
Solution
Step 1: Recall Python import syntax
In Python, modules are imported using the keyword import.
Step 2: Match the correct syntax
import agent_framework uses import agent_framework, which is valid Python syntax.
Final Answer:
import agent_framework -> Option A
Quick Check:
Python imports use 'import' keyword = A [OK]
Hint: Python imports use 'import' keyword [OK]
Common Mistakes:
Using 'include' which is not Python syntax
Using 'using' which is from other languages
Using 'require' which is JavaScript syntax
3. Given this Python code using a framework:
from agent_framework import Agent
agent = Agent(name='Helper')
print(agent.name)
What will be the output?
medium
A. Helper
B. agent
C. Agent
D. Error: Agent has no attribute 'name'
Solution
Step 1: Understand the code behavior
The code creates an Agent object with the name 'Helper' and then prints the name attribute.
Step 2: Predict the output
Since agent.name was set to 'Helper', printing it outputs 'Helper'.
Final Answer:
Helper -> Option A
Quick Check:
agent.name prints 'Helper' = D [OK]
Hint: Print attribute set during object creation [OK]
Common Mistakes:
Confusing class name with attribute value
Assuming default attribute value instead of set value
Expecting an error without reason
4. This code snippet uses a framework but has an error:
from agent_framework import Agent
agent = Agent()
print(agent.name)
What is the likely cause of the error?
medium
A. The import statement is missing a module.
B. The print statement syntax is incorrect.
C. The Agent class requires a name argument when creating an object.
D. The Agent class does not have a print method.
Solution
Step 1: Analyze the Agent object creation
The code calls Agent() without arguments, but the previous example showed Agent(name='Helper').
Step 2: Identify the error cause
Likely, the Agent class requires a name argument, so missing it causes an error when accessing agent.name.
Final Answer:
The Agent class requires a name argument when creating an object. -> Option C
Quick Check:
Missing required argument causes error = C [OK]
Hint: Check if required arguments are missing in object creation [OK]
Common Mistakes:
Blaming print syntax instead of constructor
Thinking import is incomplete
Assuming Agent has a print method
5. You want to build a custom AI agent that can chat and learn from user input. How does using a framework help you focus on your agent's unique features?
hard
A. By automatically creating your unique chat responses without coding.
B. By handling basic tasks like message passing and memory, so you only code your special logic.
C. By replacing the need to test your agent before deployment.
D. By making your agent run faster on any hardware.
Solution
Step 1: Understand framework role in agent development
Frameworks provide common features like message handling and memory management.
Step 2: Identify how this frees developer focus
Developers can then focus on coding the unique chat and learning logic without rebuilding basics.
Final Answer:
By handling basic tasks like message passing and memory, so you only code your special logic. -> Option B
Quick Check:
Frameworks handle basics, you add unique features = B [OK]
Hint: Frameworks handle basics; you add unique logic [OK]