Skip to content
Sharp

Python Internals · interview question

What does a strong engineer do when reasoning through mutability traps code?

Multiple choiceMediumchapter-19-curatedpremiumpython-internalsmutability-traps
python
def add_flag(flags: list[str] | None = None) -> list[str]:
    flags = [] if flags is None else flags
    flags.append("seen")
    return flags
Choose one answer
Answer and explanation

Correct answer

A. Narrate the data shape, the state changes, and the exact rule order step by step.

Why

Interviewers often use simple code to test whether you can reason through execution without bluffing.

Test yourself on Python Internals

A free test with instant, explained results. No account needed.

Start free test
All Python Internals questions →