Short snippets interviewers love because the obvious answer is wrong. Predict first, then read the explanation — every output below was produced by running the code.
Mutability & names
Default argument shared between calls
Multiplying a nested list
Augmented assignment on a tuple item
Rebinding vs mutating a parameter
Scope & closures
UnboundLocalError
Closures in a loop
Class variable vs instance variable
Operators & values
Chained comparisons and precedence
Floats and rounding
and / or return operands
True is an int
Iteration & generators
Exhausted iterators
Modifying a list while iterating
Generator expression evaluation time
Exceptions & finally
finally runs even after return
The else clause of a loop
Which except catches it?
Classes
MRO in diamond inheritance
__eq__ without __hash__