Python interview questions
4,305 questions across 40 topics, each with the correct answer and an explanation. Free to read.
Advanced Python
175 questions- What is the clearest sign that code around class-based context managers should be refactored?
- Which move is the best default when functools.wraps becomes part of this workflow?
- What do interviewers usually hear as a strong signal when you discuss decorator factories well?
- Which explanation would sound strongest in an interview when discussing functools.wraps?
- Which explanation would sound strongest in an interview when discussing contextlib helpers?
Architecture
200 questions- A bug appears around idempotency. What is the strongest first debugging move?
- Which explanation would best help the team align on caching?
- A senior interviewer asks for one tradeoff behind environment-based deployment. What is the strongest…
- Another engineer will maintain this code later. What choice helps the most around caching?
- A teammate submits shaky idempotency code. Which review comment is the strongest?
Automation Scripts
100 questions- If script entry points fails in production, what handling philosophy is strongest?
- If you wrote a test around input assumptions, what should the test prove first?
- You cannot rewrite everything today. What is the best incremental improvement around import/export mini…
- Which boundary choice best fits input assumptions in a maintainable Python system?
- Which explanation would sound strongest in an interview when discussing import/export mini project?
Classes and Objects
75 questions- Which option describes the most likely pitfall around dataclass basics?
- A senior interviewer asks for one tradeoff behind dataclass basics. What is the strongest follow-up?
- A bug appears around dataclass basics. What is the strongest first debugging move?
- Which option is the safer default when shipping code around dataclass basics?
- Which move is the best default when dataclass basics becomes part of this workflow?
CLI Design
75 questions- What is the clearest sign that code around runnable project shape should be refactored?
- Which response shows the healthiest evidence-first mindset around runnable project shape?
- Another engineer will maintain this code later. What choice helps the most around environment configuration?
- A teammate submits shaky runnable project shape code. Which review comment is the strongest?
- A senior interviewer asks for one tradeoff behind argparse and commands. What is the strongest follow-up?
Code Quality
50 questions- What is the clearest sign that code around mypy feedback should be refactored?
- What kind of contract clarity matters most for linters and formatters?
- What is the healthiest performance judgment around mypy feedback?
- Which naming or modeling choice is strongest for mypy feedback?
- What does a strong engineer do when reasoning through linters and formatters code?
Code Reading
50 questions- Which move is the best default when dry runs and rule narration becomes part of this workflow?
- What production risk should you worry about most if dry runs and rule narration is handled lazily?
- Which option describes the most likely pitfall around dry runs and rule narration?
- A teammate submits shaky dry runs and rule narration code. Which review comment is the strongest?
- A bug appears around dry runs and rule narration. What is the strongest first debugging move?
Code Review
75 questions- What does a strong engineer do when reasoning through abstraction discipline code?
- What production risk should you worry about most if abstraction discipline is handled lazily?
- Another engineer will maintain this code later. What choice helps the most around readability tradeoffs?
- A senior interviewer asks for one tradeoff behind abstraction discipline. What is the strongest follow-up?
- When is review quality being used in the wrong way?
Code Safety
25 questions- Which boundary choice best fits mutation and copying in a maintainable Python system?
- Another engineer will maintain this code later. What choice helps the most around mutation and copying?
- What production risk should you worry about most if mutation and copying is handled lazily?
- A senior interviewer asks for one tradeoff behind mutation and copying. What is the strongest follow-up?
- What do interviewers usually hear as a strong signal when you discuss mutation and copying well?
Concurrency
175 questions- Which explanation would sound strongest in an interview when discussing async def and await?
- If you wrote a test around cancellation, what should the test prove first?
- What production risk should you worry about most if cancellation is handled lazily?
- Which option treats cancellation as an engineering policy decision instead of a syntax trick?
- Which option describes the most likely pitfall around cancellation?
Control Flow
100 questions- Which boundary choice best fits for loops in a maintainable Python system?
- What assumption should be made explicit when working with for loops?
- What does a strong engineer do when reasoning through guard clauses code?
- Which naming or modeling choice is strongest for branching policies?
- Which option treats for loops as an engineering policy decision instead of a syntax trick?
Core Collections
175 questions- If sorting and grouping fails in production, what handling philosophy is strongest?
- A senior interviewer asks for one tradeoff behind sets. What is the strongest follow-up?
- Which explanation would best help the team align on tuples?
- Which option is the safer default when shipping code around lists?
- Which response shows the healthiest evidence-first mindset around sorting and grouping?
Data Access
125 questions- What kind of contract clarity matters most for basic sqlite queries?
- Which option is the safer default when shipping code around basic sqlite queries?
- Which response shows the healthiest evidence-first mindset around basic sqlite queries?
- A teammate submits shaky basic sqlite queries code. Which review comment is the strongest?
- Which move is the best default when basic sqlite queries becomes part of this workflow?
Data Cleanup
50 questions- Which explanation would best help the team align on normalization pipelines?
- A teammate submits shaky safe output writes code. Which review comment is the strongest?
- When is safe output writes being used in the wrong way?
- What is the clearest sign that code around safe output writes should be refactored?
- You cannot rewrite everything today. What is the best incremental improvement around normalization pipelines?
Debugging
50 questions- Which option treats tracebacks and root cause as an engineering policy decision instead of a syntax trick?
- When is logging being used in the wrong way?
- Which move is the best default when logging becomes part of this workflow?
- Which explanation would sound strongest in an interview when discussing logging?
- What assumption should be made explicit when working with logging?
Domain Modeling
125 questions- Which move is the best default when instance methods becomes part of this workflow?
- What does a strong engineer do when reasoning through properties and encapsulation code?
- If mini domain model fails in production, what handling philosophy is strongest?
- Which judgment is strongest when choosing a data shape for invariants in __post_init__?
- Which explanation would sound strongest in an interview when discussing instance methods?
Exceptions
100 questions- Which boundary choice best fits custom exceptions in a maintainable Python system?
- A teammate submits shaky custom exceptions code. Which review comment is the strongest?
- Which explanation would sound strongest in an interview when discussing raising exceptions?
- You cannot rewrite everything today. What is the best incremental improvement around custom exceptions?
- Which judgment is strongest when choosing a data shape for custom exceptions?
FastAPI
100 questions- What does a strong engineer do when reasoning through pydantic models code?
- A teammate submits shaky pydantic models code. Which review comment is the strongest?
- What do interviewers usually hear as a strong signal when you discuss api errors well?
- Which boundary choice best fits api errors in a maintainable Python system?
- What do interviewers usually hear as a strong signal when you discuss pydantic models well?
Files and Paths
50 questions- When is pathlib being used in the wrong way?
- Which response shows the healthiest evidence-first mindset around pathlib?
- What kind of contract clarity matters most for reading text?
- Another engineer will maintain this code later. What choice helps the most around pathlib?
- Which option is the safer default when shipping code around pathlib?
Functions
75 questions- What is the clearest sign that code around batch helpers should be refactored?
- Which judgment is strongest when choosing a data shape for batch helpers?
- Which boundary choice best fits batch helpers in a maintainable Python system?
- What is the healthiest performance judgment around batch helpers?
- Which move is the best default when batch helpers becomes part of this workflow?
HTTP Integration
150 questions- Which judgment is strongest when choosing a data shape for basic http clients?
- Which explanation would best help the team align on pagination and rate limits?
- A bug appears around basic http clients. What is the strongest first debugging move?
- Which response shows the healthiest evidence-first mindset around json mapping?
- Which judgment is strongest when choosing a data shape for 429s and backoff?
Interview Strategy
250 questions- What is the healthiest performance judgment around handling uncertainty?
- Which option describes the most likely pitfall around senior tradeoffs?
- What production risk should you worry about most if debugging stories is handled lazily?
- A senior interviewer asks for one tradeoff behind debugging stories. What is the strongest follow-up?
- What kind of contract clarity matters most for handling uncertainty?
Iterators and Generators
75 questions- What is the clearest sign that code around iterator protocol should be refactored?
- If you wrote a test around yield and custom generators, what should the test prove first?
- Which judgment is strongest when choosing a data shape for iterator protocol?
- What is the healthiest performance judgment around yield and custom generators?
- Which move is the best default when iterator protocol becomes part of this workflow?
Logging
25 questions- Which option treats structured diagnostics as an engineering policy decision instead of a syntax trick?
- A senior interviewer asks for one tradeoff behind structured diagnostics. What is the strongest follow-up?
- What is the healthiest performance judgment around structured diagnostics?
- If you wrote a test around structured diagnostics, what should the test prove first?
- Which judgment is strongest when choosing a data shape for structured diagnostics?
Memory
50 questions- What do interviewers usually hear as a strong signal when you discuss long-lived objects well?
- What kind of contract clarity matters most for tracing allocations?
- Which explanation would best help the team align on long-lived objects?
- Which option is the safer default when shipping code around tracing allocations?
- A bug appears around long-lived objects. What is the strongest first debugging move?
Performance
125 questions- What assumption should be made explicit when working with profiling first?
- If you wrote a test around optimization boundaries, what should the test prove first?
- What production risk should you worry about most if microbenchmarks is handled lazily?
- Which explanation would best help the team align on data structure choice?
- Which boundary choice best fits data structure choice in a maintainable Python system?
Project Tooling
125 questions- What is the clearest sign that code around entry points should be refactored?
- Which explanation would sound strongest in an interview when discussing entry points?
- Which option is the safer default when shipping code around module boundaries?
- What does a strong engineer do when reasoning through module boundaries code?
- What is the healthiest performance judgment around module boundaries?
Python Fundamentals
125 questions- Which judgment is strongest when choosing a data shape for tracing and code reading?
- Which explanation would sound strongest in an interview when discussing built-in types and none?
- When is expressions and arithmetic being used in the wrong way?
- What does a strong engineer do when reasoning through f-strings and output formatting code?
- Another engineer will maintain this code later. What choice helps the most around expressions and arithmetic?
Python Internals
175 questions- A teammate submits shaky closures and scope code. Which review comment is the strongest?
- Which option is the safer default when shipping code around closures and scope?
- Which option treats closures and scope as an engineering policy decision instead of a syntax trick?
- What kind of contract clarity matters most for closures and scope?
- Which explanation would sound strongest in an interview when discussing closures and scope?
Python Interview Questions
305 questions- What deeper point about Dictionaries and Hash Tables should a senior Python developer mention?
- When should a Python developer choose Graphs and Adjacency Lists deliberately?
- Which statement about Counter and Frequency Maps is the strongest interview answer?
- When should a Python developer choose Counter and Frequency Maps deliberately?
- Which practice avoids a common mistake with Binary Search Trees?
Pythonic Data Processing
100 questions- Which naming or modeling choice is strongest for list comprehensions?
- Which explanation would sound strongest in an interview when discussing dict comprehensions?
- Which option describes the most likely pitfall around list comprehensions?
- What assumption should be made explicit when working with set comprehensions?
- When is set comprehensions being used in the wrong way?
Refactoring
25 questions- Which naming or modeling choice is strongest for types during refactors?
- What kind of contract clarity matters most for types during refactors?
- Which option is the safer default when shipping code around types during refactors?
- Another engineer will maintain this code later. What choice helps the most around types during refactors?
- Which explanation would best help the team align on types during refactors?
Reliability
25 questions- Which move is the best default when failure policy becomes part of this workflow?
- If you wrote a test around failure policy, what should the test prove first?
- Which boundary choice best fits failure policy in a maintainable Python system?
- Which option describes the most likely pitfall around failure policy?
- What is the clearest sign that code around failure policy should be refactored?
Security
200 questions- You cannot rewrite everything today. What is the best incremental improvement around safe subprocess calls?
- What is the healthiest performance judgment around secrets management?
- What is the clearest sign that code around secrets management should be refactored?
- Which boundary choice best fits log redaction in a maintainable Python system?
- If input validation fails in production, what handling philosophy is strongest?
Serialization
50 questions- Another engineer will maintain this code later. What choice helps the most around json parsing?
- What assumption should be made explicit when working with csv parsing?
- A senior interviewer asks for one tradeoff behind csv parsing. What is the strongest follow-up?
- Which explanation would sound strongest in an interview when discussing json parsing?
- Which explanation would sound strongest in an interview when discussing csv parsing?
Service Design
125 questions- What do interviewers usually hear as a strong signal when you discuss dto mapping well?
- When is dependency injection being used in the wrong way?
- When is service layer being used in the wrong way?
- Which response shows the healthiest evidence-first mindset around dto mapping?
- Which option treats integration client shape as an engineering policy decision instead of a syntax trick?
SQL
75 questions- If you wrote a test around indexes and access patterns, what should the test prove first?
- Which move is the best default when indexes and access patterns becomes part of this workflow?
- A teammate submits shaky indexes and access patterns code. Which review comment is the strongest?
- Which option describes the most likely pitfall around indexes and access patterns?
- What is the clearest sign that code around indexes and access patterns should be refactored?
System Design
25 questions- What does a strong engineer do when reasoning through choosing the model code?
- A senior interviewer asks for one tradeoff behind choosing the model. What is the strongest follow-up?
- Which move is the best default when choosing the model becomes part of this workflow?
- Which boundary choice best fits choosing the model in a maintainable Python system?
- What is the clearest sign that code around choosing the model should be refactored?
Testing
225 questions- Another engineer will maintain this code later. What choice helps the most around arrange act assert?
- Which option treats api contract testing as an engineering policy decision instead of a syntax trick?
- When is api contract testing being used in the wrong way?
- Which option treats basic pytest assertions as an engineering policy decision instead of a syntax trick?
- Which response shows the healthiest evidence-first mindset around basic pytest assertions?
Type Hints
100 questions- What do interviewers usually hear as a strong signal when you discuss function type hints well?
- A teammate submits shaky typeddict and shaped data code. Which review comment is the strongest?
- Which explanation would best help the team align on function type hints?
- Which move is the best default when protocols becomes part of this workflow?
- When is protocols being used in the wrong way?