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.

375 questions answered14 topics14 topic groups
Pick a topic

Every topic below links to its own page with all of its questions in one place.

Read the answer

Answers are checked against current language behaviour; old-guide claims are corrected.

Jump both ways

Each topic points to the matching course lesson, and lessons point back here.

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

Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Cloud hosting for side projectsShip the portfolio project that gets you hired — free credits for new accounts.Claim credits