Python interview questions in 2026: by level, with model answers and scoring rubrics

Python interview questions fall into predictable bands. Freshers get asked about data types, mutability, and basic control flow. Intermediate candidates get decorators, generators, comprehensions, and how Python handles scope. Senior candidates get the global interpreter lock, memory management, concurrency, and design decisions.
This page gives you the Python interview questions and answers by level, with a one-line scoring note for each so an interviewer can tell a real answer from a memorized one. Candidates prep with the answers; recruiters and hiring managers use the rubric to run a defensible Python screen without being Python experts. The official Python documentation is the primary reference for the concepts below.
Most "Python interview questions" pages are long answer dumps written for the candidate only. The version below is two-sided, because in a hiring loop a question is only useful if you know what a strong answer contains.
Key Takeaways
Python questions sort cleanly by seniority: freshers get mutability and data types, intermediates get decorators and generators, seniors get the GIL, memory, and concurrency.
The most revealing intermediate topics are decorators, generators, and scope, because they separate people who write Python from people who understand it.
The GIL question is the classic senior filter: a strong answer explains what it does, why it exists, and when it does and does not matter.
Every question below has a model answer and a scoring note, so an interviewer can score consistently without deep Python expertise.
A recruiter can run this exact screen through a structured AI interview and get a scorecard, which is the point of attaching rubrics to the questions.
How Python interviews are structured in 2026
A Python interview usually has three layers. A knowledge layer (do they understand the language: data model, mutability, scope), a coding layer (can they solve a problem in Python under time pressure), and a judgment layer (do they make sensible design and performance decisions). Junior interviews weight the knowledge layer; senior interviews weight judgment.
The skill being tested is rarely trivia. An interviewer asking about decorators is checking whether the candidate understands functions as first-class objects, not whether they memorized syntax. The questions below are grouped so you can match depth to the role, and each one notes what the question is really probing.
If you are hiring Python engineers, the AI interviewer for Python developers and the Python question bank cover the role end to end. This page is the interview-questions deep dive with scoring.
Beginner and fresher Python questions
These Python interview questions for freshers confirm the candidate knows the language fundamentals.
Question: What is the difference between a list and a tuple, and why does it matter?
Model answer: A list is mutable and a tuple is immutable. Lists are for collections that change; tuples are for fixed records and can be used as dictionary keys or set members because they are hashable (when their contents are). The immutability of tuples also signals intent: this collection should not change.
Scoring note: a strong answer connects immutability to a real consequence (hashability, use as keys, intent). A weak answer says only "tuples use parentheses, lists use brackets," which is syntax, not understanding.
Question: What does it mean that Python is dynamically typed, and what are the tradeoffs?
Model answer: Variables are bound to objects at runtime and a name can refer to objects of different types over its life. The tradeoff is flexibility and speed of writing versus a class of errors that only surface at runtime. Type hints and tools like mypy recover some safety without changing Python's dynamic nature.
Scoring note: a strong answer names the runtime-error tradeoff and mentions type hints as the modern mitigation. A weak answer just says "you do not declare types."
Question: Explain mutable versus immutable types with an example of how it bites people.
Model answer: Strings, numbers, and tuples are immutable; lists, dicts, and sets are mutable. The classic bug is a mutable default argument: a function defined with a list as a default argument shares that one list across calls, so it accumulates state unexpectedly. The fix is to default to None and create the list inside the function.
Scoring note: a strong answer produces the mutable-default-argument gotcha unprompted. That single example is one of the best fresher-level signals because it separates people who have been bitten by Python from people who have only read about it.
Intermediate Python questions: decorators, generators, scope
This band separates Python users from Python understanders.
Question: What is a decorator and when would you use one?
Model answer: A decorator is a callable that takes a function and returns a function, used to wrap behavior around the original without changing its body, for cross-cutting concerns like logging, timing, caching, or access control. It works because functions are first-class objects in Python. The @decorator syntax is sugar for reassigning the name to the decorated version.
Scoring note: a strong answer grounds decorators in "functions are first-class objects" and gives a real use case. A weak answer describes the @ syntax without explaining what is actually happening.
Question: What is the difference between a generator and a list, and when would you use a generator?
Model answer: A list holds all its items in memory; a generator produces items lazily, one at a time, holding only the current state. You use a generator when the sequence is large or infinite, or when you want to stream rather than materialize, because it keeps memory flat regardless of the number of items. yield turns a function into a generator.
Scoring note: a strong answer names the memory difference and a streaming or large-data use case. A weak answer knows yield exists but cannot say why you would prefer a generator over a list.
Question: Explain Python scope and the LEGB rule.
Model answer: Name resolution follows Local, Enclosing, Global, Built-in order. A name is looked up in the local function first, then any enclosing functions, then the module global scope, then built-ins. global and nonlocal let you rebind names in outer scopes deliberately. This is why a closure can read an enclosing variable but needs nonlocal to rebind it.
Scoring note: a strong answer names LEGB and connects it to closures or to the global/nonlocal keywords. A weak answer has a vague sense of "local versus global" without the enclosing layer.
Advanced Python questions: the GIL, memory, concurrency
These advanced Python interview questions, the ones reserved for Python interview questions for experienced engineers, probe judgment and depth.
Question: What is the global interpreter lock, and when does it actually matter?
Model answer: The GIL is a mutex that allows only one thread to execute Python bytecode at a time in CPython. It matters for CPU-bound work, where threads do not give true parallelism, so you reach for multiprocessing or a native extension that releases the GIL.
It does not matter much for IO-bound work, where threads (or async) still help because the GIL is released during IO waits. Recent CPython work on a no-GIL build is changing this, but the default behavior is still GIL-bound.
Scoring note: a strong answer distinguishes CPU-bound from IO-bound and names multiprocessing or async as the respective tools. A weak answer says "the GIL makes Python slow" without the CPU-versus-IO distinction, which is the entire point.
Question: How does memory management work in Python?
Model answer: CPython uses reference counting as the primary mechanism: objects are freed when their reference count hits zero. A cyclic garbage collector handles reference cycles that counting alone cannot reclaim. Memory for small objects is managed through Python's allocator (pymalloc). Understanding reference counting explains why lingering references (in caches, closures, or module globals) cause memory to grow.
Scoring note: a strong answer names reference counting plus the cyclic collector. A weak answer says "Python has garbage collection" without knowing reference counting is the primary mechanism.
Question: How would you handle a CPU-bound workload versus an IO-bound workload in Python?
Model answer: For IO-bound work, use asyncio or threads, because the GIL is released during IO and concurrency hides the wait. For CPU-bound work, use multiprocessing to get real parallelism across cores, or push the hot path into a native extension or a library that releases the GIL. Choosing the wrong model (threads for CPU-bound work) is a common mistake that yields no speedup.
Scoring note: a strong answer maps the workload type to the right concurrency model and warns about the threads-for-CPU-bound trap. A weak answer reaches for threads regardless of workload.
Python coding and problem-solving questions
Beyond knowledge, most loops include a live coding round, and Python coding interview questions are where breadth of recall gives way to applied skill. Common prompts: manipulate a string or list with comprehensions, implement a function using a generator, use a dictionary for an O(n) lookup instead of a nested loop, or write a small class with proper __init__ and __repr__.
What the interviewer scores is not just correctness but whether the candidate reaches for Pythonic constructs (comprehensions, enumerate, zip, dict lookups) and explains their reasoning.
Scoring note for any coding round: a strong candidate narrates the approach, picks the idiomatic Python construct, and can explain the time complexity. A weak candidate writes C-style Python (manual index loops where a comprehension fits) and goes silent while coding.
The most difficult Python questions and what a strong answer looks like
The hardest questions are rarely the most obscure; they are the ones that require explaining a tradeoff. The GIL question above is the canonical one.
Others: "when would you use __slots__" (memory optimization by avoiding per-instance dicts, at the cost of dynamic attributes), "what is the difference between is and ==" (identity versus equality, and why is on small integers or interned strings can surprise you), and "how do you avoid a circular import" (restructure modules, defer the import, or move shared code to a third module). In each case the strong answer explains the why, not just the rule.
How to evaluate a Python answer without being a Python expert
If you are a recruiter or hiring manager who does not write Python, the scoring notes above are doing the heavy lifting. You do not need to know Python to tell whether a candidate distinguished CPU-bound from IO-bound work, because the note tells you what a strong answer contains. The hard part is doing it consistently, across many candidates, in a live conversation, while also probing the follow-up.
That is what a structured AI interviewer does: it runs these questions, follows up on a thin answer, and produces a scorecard with the transcript and reasoning per criterion, scored against a published rubric. We explain the approach on the methodology page, and the broader case for recruiters running technical screens is in how non-technical recruiters can evaluate engineering talent without wasting developer time.
How to practice as a candidate
Do not memorize. Interviewers push on the follow-up precisely to defeat memorized answers. Practice explaining decorators, the GIL, and generators out loud in your own words, and practice the coding round by narrating your approach.
Practice a Python interview on a role you are targeting, or run a mock interview and read the scorecard to find your thin spots. The behavioral and SQL question banks cover the rounds that usually accompany a Python screen. The structured-interview research behind the recruiter angle is Schmidt and Hunter's meta-analysis, which put structured-interview validity at about 0.51.
Frequently asked questions
What are basic Python interview questions? Fresher-level questions cover data types and mutability (list vs tuple), dynamic typing, control flow, and common gotchas like the mutable default argument. They confirm the candidate knows the language fundamentals before the interview moves to decorators, generators, and the harder topics.
What are the most difficult Python questions? The hardest ones require explaining a tradeoff rather than reciting a rule: the global interpreter lock and when it matters, when to use __slots__, the difference between is and == and why it can surprise you, and concurrency model choice for CPU-bound versus IO-bound work.
What are basic Python skills an interviewer looks for? Comfort with the data model (mutability, references), idiomatic constructs (comprehensions, generators, enumerate, zip), understanding of scope and functions as first-class objects, and the judgment to pick the right tool for a workload. At senior levels, an understanding of the GIL, memory, and concurrency.
How should a candidate prepare for a Python interview? Practice explaining concepts out loud rather than memorizing answers, since interviewers probe follow-ups. Run timed coding practice narrating your approach, and review the intermediate topics (decorators, generators, scope) and senior topics (GIL, memory, concurrency) until you can explain the why behind each.
Can a recruiter screen for Python without knowing Python? Yes, with a structured interview and a rubric. The scoring notes in this guide describe what a strong answer contains for each question. A structured AI interview can run the screen, follow up on thin answers, and return a scorecard, so the recruiter evaluates the result rather than the code.
How many Python questions should an interview cover? A focused first-round screen usually covers 5 to 8 questions across the knowledge and coding layers, weighted to the role's seniority. Depth on a few questions, with follow-ups, beats breadth across many, because the follow-up is where memorized answers break down.
Run a defensible Python screen
The structure is the point: questions, model answers, and a scoring note, so the same page serves a candidate prepping and a recruiter screening. Python interviews are hard to run consistently because the SERP is full of question lists but none tell the interviewer how to score. The rubric notes here close that gap.
See a sample candidate scorecard for a Python role, run one screen through it, and decide whether the rubric matches what you would have written. That is how this question list becomes a repeatable hiring process rather than a study sheet.
By TK, Growth at Expert Hire. Last updated June 25, 2026. Reviewed by Anand Suresh, CPO at Expert Hire.
Ready to Transform Your Hiring?
Start your free trial to see how Expert Hire can help you screen candidates faster and smarter.