Anyone who has watched candidates prepare knows the pattern. They memorise the difference between a list and a tuple, then freeze the moment an interviewer asks why that difference matters for a hash key. The questions that decide offers are rarely trivia. They test whether a person understands how Python behaves under the hood and can reason about trade-offs while typing.

The set below is grouped by difficulty so preparation can move from warm-up to pressure. Companies known for asking versions of these include the ones listed here, drawn from published interview experiences and engineering blogs rather than guesswork.
| How to use this set: Read the question, cover the answer, and speak the response before checking. Interviewers score clarity of reasoning, not word-perfect recall. If a follow-up column is shown, expect it, because that is where most candidates lose points. |
These open almost every phone screen. The goal is not to catch anyone out. It is to confirm the basics are genuinely solid before the round moves on. Answering with a concrete reason, not just a definition, is what separates a pass from a strong pass.
Q1 What is the difference between a list and a tuple, and when does it matter? Easy A list is mutable and a tuple is immutable. The practical point interviewers want: because tuples are immutable and hashable, they can be dictionary keys or set members, while lists cannot. Tuples also carry a small memory and speed advantage for fixed collections. |
Q2 How does Easy == compares values, is compares identity, meaning whether two names point to the same object in memory. A frequent trap: small integers and short strings are cached by CPython, so |
Q3Explain mutable versus immutable with a bug it causes. Easy Strings, numbers, and tuples are immutable; lists, dicts, and sets are mutable. The classic bug is a mutable default argument:
The fix is |
Q4 What does a list comprehension give over a loop, and where is a generator better? Easy+ A comprehension is faster and reads as one expression. A generator expression, written with parentheses, produces items lazily and holds one at a time, so it wins on memory for large or infinite streams. Saying "use a generator when the full list will not fit comfortably in memory" lands well. |
| Structure | Ordered | Mutable | Duplicates | Typical use |
|---|---|---|---|---|
list | Yes | Yes | Yes | Ordered, changing sequence |
tuple | Yes | No | Yes | Fixed record, dict key |
set | No | Yes | No | Membership, dedup |
dict | Yes (3.7+) | Yes | Keys unique | Lookups by key |
This section decides whether a candidate is treated as junior or mid-level. Companies with heavy backend and infrastructure work, Uber and Nvidia among them, lean on it hard because performance problems trace back here.

Q5 What is the Global Interpreter Lock, and how does it shape design? Medium The GIL is a mutex in CPython that lets only one thread execute Python bytecode at a time. Threads still help with input and output bound work because the lock releases during blocking calls, but they do not speed up CPU bound work. For parallel computation the answer is |
Q6 How does Python manage memory and garbage collection? Medium CPython uses reference counting as the primary mechanism, freeing an object the moment its count hits zero. A cyclic garbage collector runs on top to catch reference cycles that counting alone cannot reclaim. Mentioning that objects live in a private heap managed by the interpreter shows depth. |
Q7 Deep copy versus shallow copy: what actually differs? Medium A shallow copy duplicates the outer container but shares references to nested objects, so mutating a nested list shows up in both copies. A deep copy recursively duplicates everything. Naming |
Best for I/O bound tasks: network calls, file reads, waiting on a database. The GIL releases during the wait.
Best for CPU bound tasks: each process has its own interpreter and memory, sidestepping the GIL at the cost of heavier startup.
Design-leaning roles push here. Microsoft and Atlassian interviewers often start with a small class and grow it, watching how the candidate reasons about inheritance and encapsulation.
Q8 What is the difference between Medium+
|
Q9 Explain method resolution order and how Python handles multiple inheritance. Hard Python uses the C3 linearisation algorithm to build a single, predictable ordering of parent classes. |
Q10 Class variable versus instance variable, with a gotcha. Medium A class variable is shared across instances; an instance variable belongs to one object. The gotcha is a mutable class variable such as a shared list, where appending through one instance is visible to all. Reassigning through an instance quietly creates a new instance variable instead. |
Q11 What do Medium A class method receives the class as its first argument ( |
Strong answers here move a candidate up a level. Stripe and Netflix are known for probing async and generator internals because their systems live or die on I/O throughput.
Q12 Write a decorator that times a function. Medium
The detail interviewers wait for is |
Q13 What is the difference between an iterator and a generator? Medium An iterator is any object implementing |
Q14 What does Medium+
|
Q15 Explain Hard Asyncio runs a single-threaded event loop. |
Q16What is a context manager and why use Medium A context manager defines |
Every list of Python questions repeats FizzBuzz. Real loops move past it fast. Below are the problems that recur in shared write-ups, with the pattern each one is really checking.
| Problem | Pattern tested | Optimal complexity | Seen at |
|---|---|---|---|
| Two Sum | Hash map lookup | O(n) time, O(n) space | Amazon, Google |
| Reverse a linked list | Pointer manipulation | O(n) time, O(1) space | Meta, Microsoft |
| Valid anagram | Counting with dict | O(n) time | Adobe, Airbnb |
| Merge intervals | Sorting then sweep | O(n log n) | Google, Stripe |
| LRU cache | Dict + doubly linked list | O(1) get/put | Amazon, Atlassian |
| Longest substring, no repeat | Sliding window | O(n) time | Meta, Spotify |
Q17 Solve Two Sum and explain the trade-off. Medium
The brute force is O(n squared). The hash map version trades O(n) extra space for O(n) time. Stating that trade-off out loud is often worth more than the code itself. |
Q18 Find the first non-repeating character in a string. Medium
Reaching for |
Q19 Reverse a singly linked list in place. Hard
The three-pointer walk is the expected O(1) space solution. Doing it recursively is fine too, but the interviewer will ask about stack depth. |
A pattern worth memorising: the sliding window covers a surprising share of string and array questions asked at Meta and Spotify. Two Sum trains the hash-map habit, and merge intervals trains sort-then-sweep. Drilling those three patterns prepares a candidate for far more than three questions.
print with a list return.s == s[::-1], then asked to do it without extra space.Counter or defaultdict.functools.lru_cache.Senior loops replace puzzles with open builds. The prompt is broad, and the score comes from structure, naming, and how the candidate handles edge cases without being told.
Design a rate limiter
Token bucket or sliding window. Watch for thread safety and what happens at the reset boundary.
Build an in-memory key-value store
Support get, set, and TTL expiry. Extension: add a snapshot or transaction.
Parse and query a log file
Stream with a generator instead of loading it whole. Aggregate by field.
URL shortener
Encoding scheme, collision handling, and the lookup data structure.
Q20 How would exceptions be handled in a service that must never crash on one bad record? Medium Catch the narrowest exception type around the risky operation, log the offending record with context, continue the loop, and surface a count of failures at the end. The anti-pattern to call out is a bare |
| # | Question | One-line anchor |
|---|---|---|
| 22 | Difference between append and extend | Add one item vs merge an iterable |
| 23 | How does dict maintain insertion order? | Guaranteed since 3.7, was an implementation detail in 3.6 |
| 24 | What is a lambda and its limit? | Single expression, no statements |
| 25 | Explain __slots__ | Skips per-instance dict, saves memory |
| 26 | Difference between @property and a method | Attribute access syntax with logic behind it |
| 27 | What does zip return in Python 3? | A lazy iterator, not a list |
| 28 | How does string interning work? | CPython caches some strings for identity speed |
| 29 | Explain try / except / else / finally | else runs only if no exception |
| 30 | What is duck typing? | Behaviour over declared type |
| 31 | Difference between sort and sorted | In place vs returns a new list |
| 32 | What is a metaclass? | The class of a class, controls creation |
| 33 | How to merge two dicts in modern Python? | The | operator since 3.9 |
| 34 | Explain enumerate and its start argument | Index and value without manual counters |
| 35 | What is monkey patching? | Replacing attributes at runtime, use sparingly |
| 36 | Difference between @abstractmethod and a normal method | Forces subclasses to implement |
| 37 | How does defaultdict differ from dict? | Auto-creates missing keys with a factory |
| 38 | What is the walrus operator? | Assignment inside an expression, := |
| 39 | Explain truthiness of empty containers | Empty list, dict, string are falsy |
| 40 | Difference between range and a list | range computes on demand |
| 41 | How do type hints affect runtime? | They do not, unless a tool enforces them |
| 42 | What is __repr__ vs __str__? | Debug view vs readable view |
| 43 | Concurrency versus parallelism | Interleaving vs simultaneous execution |
| 44 | How to profile slow Python code? | cProfile, then targeted timeit |
| 45 | Why do dict keys need hash and equality? | Keys need consistent hash and == |
Reviewing feedback forms surfaces the same failures again and again. Knowing the answer is only half the battle; how it is delivered decides the rest.
Preparation plan that works: spend the first week on sections one to three until every answer is automatic, the second week drilling the six coding patterns above, and the final days rehearsing out loud with a timer. Speaking answers is a different skill from knowing them, and it is the one that gets tested.
After working through these questions in mock rounds and comparing them against what candidates actually report from real loops, one thing stands out. The interview is not a memory test. Every question here rewards a person who can explain the reasoning behind a choice, name the trade-off, and stay calm through a follow-up. A candidate who understands why a tuple can be a dict key, why the GIL shapes a threading decision, and why a generator saves memory will handle variants of these questions that no list can fully predict.
The forty-five questions in this set are not exhaustive, and no set could be. What they do is cover the ground that keeps recurring at the companies named at the top, from the warm-up screen to the senior machine-coding round. Time spent here is time spent on the parts of Python that interviewers genuinely care about, rather than trivia that rarely decides an offer. Prepare the patterns, practise speaking the answers, and the questions on the day will feel familiar rather than foreign.
Comments