Python Interview Questions
The data model, closures and decorators, generators, the GIL and when to reach for threads, processes or asyncio, plus the pitfalls that bite in production — mutable defaults, late binding, and blocking the event loop.
Showing 1–20 of 100
#1What does it mean that everything in Python is an object?
#2What is the difference between mutable and immutable types, and why does it matter?
#3Why is a mutable default argument dangerous?
#4What is the difference between is and ==?
#5How does Python scoping work — what is LEGB?
#6What is the difference between a shallow and a deep copy?
#7What are dunder methods and which ones matter most?
#8What is the difference between __new__ and __init__?
#9What are Python's truthiness rules?
#10How does Python manage memory?
#11What is duck typing and how does it interact with type hints?
#12What does the walrus operator do and when should you use it?
#13What is the difference between args and kwargs, and positional-only parameters?
#14How do Python imports actually work?
#15How is a Python list implemented and what are its complexities?
#16How does a Python dict work and what guarantees does it give?
#17When would you use a tuple instead of a list?
#18What is collections.defaultdict and when is it better than dict?
#19What is a deque and when do you need one?
#20What is the difference between a set and a frozenset?
Showing 1–20 of 100
Ask Aria about Python
Sign in to chat with Aria
All 100 Python questions at a glance
- What does it mean that everything in Python is an object?(Medium)
- What is the difference between mutable and immutable types, and why does it matter?(Easy)
- Why is a mutable default argument dangerous?(Easy)
- What is the difference between is and ==?(Easy)
- How does Python scoping work — what is LEGB?(Medium)
- What is the difference between a shallow and a deep copy?(Medium)
- What are dunder methods and which ones matter most?(Medium)
- What is the difference between __new__ and __init__?(Hard)
- What are Python's truthiness rules?(Easy)
- How does Python manage memory?(Hard)
- What is duck typing and how does it interact with type hints?(Hard)
- What does the walrus operator do and when should you use it?(Medium)
- What is the difference between args and kwargs, and positional-only parameters?(Medium)
- How do Python imports actually work?(Medium)
- How is a Python list implemented and what are its complexities?(Medium)
- How does a Python dict work and what guarantees does it give?(Medium)
- When would you use a tuple instead of a list?(Easy)
- What is collections.defaultdict and when is it better than dict?(Easy)
- What is a deque and when do you need one?(Medium)
- What is the difference between a set and a frozenset?(Easy)
- What are dataclasses and when would you use one over a NamedTuple or a plain class?(Medium)
- How do you sort with a custom key efficiently?(Medium)
- What is the difference between a list comprehension and a generator expression?(Medium)
- How do you merge dictionaries and what are the options?(Easy)
- What is collections.Counter useful for?(Easy)
- When would you use heapq or bisect?(Hard)
- What is a closure and what is the late binding gotcha?(Hard)
- How does a decorator work?(Medium)
- What does functools.lru_cache do and when is it unsafe?(Medium)
- What is the difference between a function and a method, and what do staticmethod and classmethod do?(Medium)
- How would you write a retry decorator?(Medium)
- What is a context manager and how do you write one?(Medium)
- What are first-class functions and how do partial and higher-order functions help?(Medium)
- When should you use a lambda and when should you not?(Easy)
- How do you write a decorator that works on both functions and methods?(Hard)
- What is functools.singledispatch?(Hard)
- What are type hints good for if Python ignores them at runtime?(Medium)
- How do you handle exceptions well in Python?(Medium)
- How does multiple inheritance and the MRO work?(Hard)
- What are properties and when should you use one?(Medium)
- What is the descriptor protocol?(Hard)
- What are __slots__ and when do they help?(Hard)
- What is a metaclass and when would you actually need one?(Hard)
- What is an abstract base class and how does it differ from a Protocol?(Hard)
- What does the underscore convention mean in Python?(Easy)
- How do you implement equality and hashing correctly?(Medium)
- What is the difference between composition and inheritance in Python specifically?(Medium)
- What does super() actually do?(Hard)
- How do you make a class iterable, and what is the difference between iterable and iterator?(Medium)
- What is the point of __repr__ and how should you write one?(Easy)
- What is a generator and how does yield work?(Medium)
- What does yield from do?(Hard)
- How do you process a large file without loading it into memory?(Medium)
- What is itertools and which functions are worth knowing?(Medium)
- What is the difference between an iterator and a generator?(Medium)
- What is generator send() used for?(Hard)
- How do comprehensions compare to map and filter?(Easy)
- What happens if you modify a collection while iterating it?(Medium)
- How do you implement pagination or chunking over an iterable?(Medium)
- What are the memory implications of generators versus lists in a pipeline?(Medium)
- What is the GIL and what does it actually prevent?(Medium)
- When do you use threading, multiprocessing, and asyncio?(Medium)
- How does asyncio actually work?(Hard)
- What is the difference between awaiting sequentially and using gather?(Medium)
- What happens if you call a blocking function inside async code?(Hard)
- What is the difference between a coroutine, a task, and a future?(Hard)
- How do you limit concurrency in asyncio?(Hard)
- What is multiprocessing and what are its costs?(Medium)
- What is concurrent.futures and when is it the right abstraction?(Medium)
- How do you share state safely between threads in Python?(Hard)
- What is asyncio.Queue used for?(Medium)
- How do you handle timeouts and cancellation in asyncio?(Hard)
- What is the difference between asyncio and threading for a web server?(Hard)
- What are common asyncio mistakes?(Hard)
- How would you speed up a CPU-bound Python workload?(Medium)
- What changes with the free-threaded build in Python 3.13?(Hard)
- What standard library modules should every backend Python developer know?(Easy)
- How should you handle dates and times correctly?(Medium)
- How should logging be configured in an application?(Medium)
- What is the difference between pathlib and os.path?(Easy)
- How do you manage configuration and secrets in a Python application?(Medium)
- What is the difference between random and secrets?(Medium)
- How do you run a subprocess safely?(Medium)
- What is the difference between pip, venv, poetry and uv?(Medium)
- What is the walrus of string formatting — which method should you use?(Easy)
- What is the difference between JSON serialisation options in Python?(Medium)
- Why do most Python projects use pytest rather than unittest?(Easy)
- What are pytest fixtures and what do the scopes mean?(Medium)
- How does mocking work in Python and what should you mock?(Medium)
- How do you test code that depends on the current time?(Medium)
- What is parametrised testing and why is it valuable?(Medium)
- How do you test async code?(Hard)
- What makes a Python test suite slow, and how do you fix it?(Medium)
- What is a flaky test and how do you deal with one?(Medium)
- How do you profile a Python application?(Medium)
- What are the most common accidental performance problems in Python?(Medium)
- How do you find and fix a memory leak in Python?(Hard)
- When should you reach for NumPy instead of built-in types?(Medium)
- What Python-specific things would you check in a code review?(Medium)
- What distinguishes idiomatic Python from code that works?(Medium)