Bird
0
0

Given this state schema class in Langchain:

medium📝 component behavior Q13 of 15
LangChain - LangGraph for Stateful Agents
Given this state schema class in Langchain:
class UserState:
    def __init__(self):
        self.name = ''
        self.age = 0

state = UserState()
state.name = 'Alice'
state.age = 30
print(state.name, state.age)

What will be printed?
AAlice 30
B'' 0
Cname age
DError: name and age not defined
Step-by-Step Solution
Solution:
  1. Step 1: Understand class initialization

    The UserState class initializes name as empty string and age as 0.
  2. Step 2: Check assigned values before print

    state.name is set to 'Alice' and state.age to 30 before printing.
  3. Final Answer:

    Alice 30 -> Option A
  4. Quick Check:

    Assigned values printed = Alice 30 [OK]
Quick Trick: Print shows assigned values, not defaults [OK]
Common Mistakes:
MISTAKES
  • Assuming default values print instead of assigned
  • Confusing variable names with strings
  • Expecting error due to missing attributes

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More LangChain Quizzes