Interview Q&A · Python
Python Interview Questions & Answers
All 375 Python interview questions — fundamentals, containers, OOP, generators, decorators, asyncio and 45 coding problems — with worked solutions, interview tips and the traps to avoid. This bank holds 375 questions across 14 topics and 14 topic groups. Every answer is written for current Python versions, and each topic links to matching course lessons where they exist.
Every topic below links to its own page with all of its questions in one place.
Answers are checked against current language behaviour; old-guide claims are corrected.
Each topic points to the matching course lesson, and lessons point back here.
Featured questions in this bank
Python Fundamentals
What is Python?
Python is a high-level, general-purpose, interpreted programming language known for readable syntax, dynamic typing, and a large standard library. It supports multiple paradigms — procedural, object-oriented, and functional.…
Read the full answer →Python Fundamentals
What are the key features of Python?
Python's standout features are readable syntax, dynamic typing, automatic memory management, an extensive standard library, cross-platform portability, and strong support for multiple programming paradigms. Interviewers usually…
Read the full answer →Strings, Lists, Tuples, Sets & Dictionaries
What are strings in Python, and how are they represented internally?
A string (str) is an immutable sequence of Unicode characters. Internally, CPython stores strings as arrays of fixed-width code points, choosing the smallest representation (1, 2, or 4 bytes per character) that fits the string's…
Read the full answer →Strings, Lists, Tuples, Sets & Dictionaries
What is string slicing, and how does it work?
Slicing extracts a sub-sequence from a string (or any sequence) using sequence[start:stop:step]. start is inclusive, stop is exclusive, and step controls direction and stride; all three are optional. Omitting start defaults to…
Read the full answer →Functions
How do you define a function in Python?
Functions are defined with the def keyword, a name, a parenthesized parameter list, and an indented body. A function returns None implicitly if it has no explicit return statement. Unlike some languages, Python doesn't require…
Read the full answer →Functions
What is the difference between parameters and arguments?
A parameter is the name listed in a function's definition; an argument is the actual value passed in when the function is called. The terms are often used interchangeably in casual conversation, but interviewers sometimes probe…
Read the full answer →Python Fundamentals
25 questions across 1 topic — The vocabulary every Python interview opens with — what the language is, how it executes, how typing and scope work, and the syntax rules that trip up developers arriving from other languages.
Strings, Lists, Tuples, Sets & Dictionaries
30 questions across 1 topic — The built-in containers and the questions that follow them everywhere: mutation, hashing, copying, comprehensions and the cost of each choice.
Functions
25 questions across 1 topic — Defining and calling functions, the parameter rules interviewers probe, closures, recursion and the functional tools in the standard library.
Object-Oriented Python
35 questions across 1 topic — Classes, objects, inheritance and the dunder protocol — including MRO, the diamond problem and how Python implements encapsulation without real access modifiers.
Exception Handling
15 questions across 1 topic — try/except/else/finally, raising and chaining, the exception hierarchy, and what production logging of exceptions should look like.
Iterators & Generators
20 questions across 1 topic — The iterator protocol, yield, lazy evaluation and the memory arguments that decide between a generator and a list.
Decorators
15 questions across 1 topic — Decorators from first principles: the wrapper pattern behind them, functools.wraps, decorators with arguments and the ones you already use in production.
Modules, Packages & Virtual Environments
15 questions across 1 topic — Imports and the import cache, packages and __init__.py, pip, virtual environments and how a project keeps its dependencies reproducible.
File Handling
15 questions across 1 topic — Reading and writing files safely, context managers, text encodings, and the CSV/JSON work that shows up in almost every data question.
Advanced Python
35 questions across 1 topic — The internals interviewers probe on senior rounds — memory model, the GIL, slots, profiling, descriptors and the corners of the language standard guides skip.
Concurrency & Parallelism
25 questions across 1 topic — Threads, processes and asyncio — what each one is actually good at, what the GIL prevents, and how to choose under a real workload.
Python Coding Interview Questions
45 questions across 1 topic — 45 classic coding problems with the expected approach, a step-by-step walkthrough, an idiomatic Python solution and its complexity — the rounds where you write code.
Scenario-Based Interview Questions
25 questions across 1 topic — Engineering-judgment questions about production systems — debugging, profiling, caching, configuration, testing and migration decisions, with the trade-offs spelled out.
Rapid-Fire Revision
50 questions across 1 topic — The handbook's 50 rapid-fire question/answer pairs — one-line answers spanning the whole guide, for a final pass the night before an interview.
Recommended resourcesAffiliate links · may earn us a commission