45 Python Interview Questions That Reveal Real Skill

On this page
- Beginner Python Interview Questions
- Intermediate Python Interview Questions
- Senior Python Interview Questions
- Python Pitfalls That Reveal Experience
- How to Structure a Python Technical Screen
- 30-Minute Screen
- 60-Minute Technical Interview
- Scoring Python Interview Answers
- Explore All 45 Python Interview Questions
Most Python interview questions you find online test trivia, not engineering judgment. Asking "what's the difference between a list and a tuple?" tells you nothing about whether a candidate can design a clean data pipeline or debug a memory leak in production. The questions you ask should create a gradient — accessible enough for juniors to demonstrate fundamentals, deep enough for seniors to show mastery. This guide highlights 10 of the best Python interview questions from our full set of 45, organized by difficulty, with guidance on what separates average answers from great ones.
TL;DR: 10 highlighted Python interview questions across fundamentals, OOP, decorators, concurrency, and common pitfalls — with reference answers and scoring tips. The full set of 45 questions with answers is available on our Python interview questions page.
Beginner Python Interview Questions
These questions establish whether a candidate has a solid foundation. Every Python developer should handle these — the depth of their answers reveals the level.
How does Python handle mutable default arguments in functions?
This is a classic trap that separates experienced Python developers from beginners. Default arguments are evaluated once at function definition, not at each call. Mutable defaults like lists or dicts are shared across calls.
def append_to(item, target=[]): target.append(item) return target append_to(1) # [1] append_to(2) # [1, 2] — not [2]!
Look for the idiomatic fix using None as a sentinel: target=None with if target is None: target = []. Candidates who know this pattern have been bitten by this bug before.
Explain the difference between is and == in Python. When would you use each?
== checks value equality via __eq__. is checks identity — whether two references point to the same object in memory. Strong candidates mention CPython's integer interning (small integers -5 to 256 share objects) and explain why is should only be used for singletons like None, True, and False.
Tip: Follow up with "Can you use a list as a dictionary key?" to bridge into hashability — a concept that separates developers who understand Python's data model from those who just memorize syntax.
Intermediate Python Interview Questions
These questions separate developers who write Python from developers who write Pythonic Python. They test familiarity with the language's most powerful abstractions.
Write a decorator that accepts arguments — for example, a @retry(max_attempts=3) decorator.
This requires a three-level nested function pattern, which is where many candidates stumble.
import functools import time def retry(max_attempts=3, delay=1): def decorator(func): @functools.wraps(func) def wrapper(*args, **kwargs): for attempt in range(max_attempts): try: return func(*args, **kwargs) except Exception: if attempt == max_attempts - 1: raise time.sleep(delay) return wrapper return decorator @retry(max_attempts=5, delay=0.5) def fetch_data(): pass
What to look for: Understanding that @retry(max_attempts=3) calls retry(max_attempts=3) which returns the actual decorator. Candidates who can implement this without hesitation have strong closure fundamentals.
How do context managers work? Write one using the decorator approach.
The contextlib.contextmanager decorator uses a generator with a single yield. Class-based context managers implement __enter__ and __exit__ directly.
from contextlib import contextmanager @contextmanager def managed_file(path, mode): f = open(path, mode) try: yield f finally: f.close()
What to look for: Does the candidate use try/finally for guaranteed cleanup? Can they explain why finally matters — resource cleanup must happen even if the body raises? This pattern applies broadly to any temporary state changes.
What is the difference between a generator and a list comprehension? When would you choose each?
List comprehensions build the entire list in memory. Generators yield items lazily, one at a time. The practical distinction matters for large datasets — a generator processing a 10GB file uses constant memory, while a list comprehension would try to load everything. Strong candidates mention that generators are single-use (exhausted after one iteration) while lists support multiple passes.
Key takeaway: Intermediate questions test whether a candidate thinks in Python idioms. Developers who reach for
forloops when a generator expression fits, or who can't write a decorator from scratch, are still thinking in another language.

Senior Python Interview Questions
Senior questions test whether a developer understands what happens beneath the abstraction layer — concurrency, memory management, and CPython internals.
What is the Global Interpreter Lock (GIL)? When would you use threading vs multiprocessing vs asyncio?
The GIL is a mutex that prevents multiple native threads from executing Python bytecode simultaneously. It exists because CPython's reference counting isn't thread-safe. The key follow-up maps to workload types: threading for I/O-bound work (GIL is released during system calls), multiprocessing for CPU-bound work (true parallelism), asyncio for high-concurrency I/O (thousands of connections, single thread). Candidates who explain the trade-offs — memory overhead of processes, complexity of async, GIL limitations — demonstrate real production experience.
How does Python's garbage collector work?
CPython uses reference counting as its primary mechanism — when an object's count hits zero, it's deallocated immediately. But reference counting can't handle circular references, so Python has a generational garbage collector that periodically scans for cycles. Strong candidates mention the three generations (0, 1, 2) and the gc module for manual control.
Tip: Ask "Why isn't reference counting sufficient on its own?" — candidates who can explain the circular reference problem with a concrete example have debugged real memory issues.
Python Pitfalls That Reveal Experience
These questions test battle scars, not textbook knowledge. Developers who've shipped production Python recognize these patterns immediately.
What is the output of this code? Why?
def create_multipliers(): return [lambda x: x * i for i in range(5)] for multiplier in create_multipliers(): print(multiplier(2)) # Prints 8, 8, 8, 8, 8 — not 0, 2, 4, 6, 8
Python's most infamous closure gotcha. The lambdas all share the same variable i, which has the value 4 after the loop completes. The fix is to capture i as a default argument: lambda x, i=i: x * i. Candidates who've been burned by this in production recognize it instantly.
What is the difference between + and += for lists?
a = [1, 2, 3] b = a a = a + [4, 5] print(b) # [1, 2, 3] c = [1, 2, 3] d = c c += [4, 5] print(d) # [1, 2, 3, 4, 5]
a + [4, 5] creates a new list and rebinds a — b still references the original. c += [4, 5] calls list.__iadd__, which mutates in place — so d sees the change. This distinction between __add__ and __iadd__ catches developers who assume += is just shorthand.
Key takeaway: Pitfall questions don't test knowledge — they test experience. A candidate who immediately recognizes the late-binding closure problem has debugged real Python applications.
How to Structure a Python Technical Screen
Knowing the right questions is half the battle. Organizing them into a structured interview format ensures consistent evaluation.
30-Minute Screen
- Minutes 0-2: Introduction — brief role overview, set expectations
- Minutes 2-10: Fundamentals rapid-fire — 3-4 conceptual questions (data types, mutable defaults,
*args/**kwargs) - Minutes 10-22: One coding challenge — LRU cache, anagram grouping, or memoization decorator
- Minutes 22-28: Deep dive — decorators and generators for mid-level, GIL and concurrency for senior
- Minutes 28-30: Candidate questions
60-Minute Technical Interview
- Minutes 0-5: Warmup — a relaxed fundamentals question
- Minutes 5-20: Core concepts — 4-5 questions escalating in difficulty (OOP, decorators, generators)
- Minutes 20-40: Two coding challenges — one implementation and one debugging (pitfall code)
- Minutes 40-50: Architecture discussion — concurrency strategy, module design, error handling
- Minutes 50-55: Candidate questions
- Minutes 55-60: Interviewer notes — score immediately while context is fresh

Building reusable interview templates with an interview template builder ensures every interviewer on your team asks calibrated questions at the right difficulty level.
Scoring Python Interview Answers
Consistent scoring eliminates the "gut feeling" problem. Intervy uses a 5-point scale for every question as part of your interview scoring tool workflow.
- Strong No (1) — the candidate cannot answer or gives fundamentally incorrect information
- No (2) — partial understanding, but significant gaps or misconceptions
- Maybe (3) — factually correct but surface-level, no reasoning or practical examples
- Yes (4) — solid answer with trade-offs, reasoning, or real-world context
- Strong Yes (5) — exceptional depth — connects concepts, mentions edge cases unprompted, offers alternatives
| Question | Maybe (3) | Yes (4) | Strong Yes (5) |
|---|---|---|---|
| What is the GIL? | Defines it as a mutex | Explains why it exists | Discusses I/O vs CPU impact |
| Mutable default args | Identifies the bug | Shows the None fix | Explains evaluation timing |
| Late-binding closures | Gets the output right | Explains shared variable | Shows default arg fix |

An interview question generator like Ivy can help you quickly build question sets calibrated to specific roles and levels — then score consistently across your team.
Explore All 45 Python Interview Questions
This guide highlighted 10 questions to give you a taste of what to ask and what to look for. The complete set of 45 Python interview questions — with full answers, code examples, difficulty ratings, and category tags — is available on our dedicated Python interview questions page.
For a broader view of technical interviewing, see our complete guide to technical interview questions. If you're hiring for JavaScript or frontend roles, check out our JavaScript interview questions guide or our React interview questions guide.
All 45 questions are also available as a ready-to-import set in Intervy. Head to the Export / Import page, select "Python Interview" from the Sample Interview Data dropdown, and click Load — organized by category, tagged by difficulty, and ready to drop into your next interview template.