What this Python code-reading question tests
This is a medium-difficulty question that requires careful attention to Python's object model and how language features interact. Rather than asking you to write code, it presents a snippet and asks you to predict its output—a skill that matters in both interviews and code review.
Questions like this probe whether you understand the subtle behaviour of Python's core mechanisms: how names bind to objects, how scope works, and how built-in functions and methods behave in edge cases. Interviewers use them to see if you can read unfamiliar code quickly and reason about what it does without running it.
- Name binding and object references
- Scope resolution (LEGB rule)
- Mutation vs. immutability
- Built-in type behaviour and method side effects