Python interview warm-up
Mutable defaults, closures, generators, decorators and dataclasses — plus classic problems.
- Mutable Default Arguments Default values are evaluated once, at definition time.
- Late-Binding Closures Lambdas look up variables when called, not when created.
- List Multiplication Shares Rows `[[0] * 3] * 3` creates three references to one row.
- Lazy chunked() Generator Yield fixed-size lists from any iterable — lazily, so it works on infinite streams.
- Decorator with Arguments: @retry Write a parameterised decorator that retries selected exceptions and preserves metadata.
- Immutable Money Value Object (dataclasses) Use a frozen, ordered dataclass with __add__ and __str__ for money.
- Group Anagrams Group words that are anagrams of each other.
- Top Endpoints from Access Logs Parse web-server log lines and return the most requested paths.
- LRU Cache A fixed-capacity cache that evicts the least recently used key, with O(1) get and put.