Python interview practice
Python Developer Interview Questions
Language skills for everyday engineering
50 executable practice questions from easy to hard covering core Python, OOP, errors, generators, decorators, standard-library tools, parsing, caching and asynchronous code.
Easy (12)
- Count the most frequent wordsRead free
- Reverse word order
- Check a palindrome while ignoring punctuation
- Group words by first letter
- Invert a mapping without losing keys
- Read a nested value safely
- Build running totals
- Compare two tag lists with sets
- Format an amount for display
- Rotate a list with slices
- Parse integers and count failures
- Use all() and any() correctly
Medium (27)
- Avoid shared mutable default argumentsRead free
- Copy nested data without aliasing
- Stable deduplication
- Bind loop values in closures
- A counting decorator that preserves metadata
- Yield batches with a generator
- Flatten nested lists lazily
- Implement the iterator protocol
- Restore state after a context exits
- Preserve exception causes
- Use a frozen dataclass
- Sort records with an explicit tie policy
- Apply duck typing
- Measure memoization
- Dispatch by argument type
- Sum money with an explicit rounding policy
- Normalize aware datetimes
- Parse quoted CSV correctly
- Project records without losing falsey values
- Check lexical path containment
- Validate a whole identifier
- Avoid silent zip truncation
- Merge configuration overrides
- Gather asynchronous tasks in input order
- Bound cooperative concurrency
- Retry with capped exponential backoff
- Wrap text to a fixed width
Hard (11)
- Simulate an LRU cacheRead free
- Order tasks by their dependencies
- Build a sliding-window rate limiter
- Evaluate arithmetic without eval()
- Validate attributes with a descriptor
- Run an async producer-consumer pipeline
- Sort semantic versions correctly
- Rebuild nested JSON from dotted keys
- Diff two nested configurations
- Register plugins with __init_subclass__
- Keep a running average with a coroutine