5 exercises — choose the best-structured answer to common Python Backend Developer interview questions. Focus on precise vocabulary, correct use of technical terms, and demonstrating real experience.
Structure for Python backend interview answers
Name the async primitive: coroutine, event loop, gather, create_task — with the specific concurrency model it belongs to
Explain event loop mechanics: describe what await does (suspends and yields to event loop) and when the GIL is released
Address I/O vs CPU bound: always state which concurrency tool is appropriate for each workload type
Mention profiling tools: asyncio debug mode, cProfile for CPU, py-spy for live profiling
0 / 10 completed
1 / 10
The interviewer asks: "How does Python's asyncio event loop work, and how is async concurrency different from parallelism?" Which answer best explains Python's async model?
Option B is strongest: it precisely defines the event loop as single-threaded (eliminating the "runs faster by parallelism" misconception), distinguishes concurrency from parallelism explicitly, explains what await does mechanically (suspends, yields to event loop), names both gather and create_task, gives the I/O-bound vs CPU-bound decision rule with specifics, and provides the concrete solution for CPU-bound work (run_in_executor). Key structure: single-threaded event loop → concurrency without parallelism → await suspends and yields → gather/create_task → I/O-bound preferred → run_in_executor for CPU-bound. Option C mentions multiprocessing correctly but attributes it to the GIL (partially correct but imprecise — the real reason is blocking the event loop). Option D is accurate but surface-level and does not give the I/O vs CPU decision rule.
2 / 10
The interviewer asks: "What is the GIL in CPython, and how does it affect your choice of concurrency approach?" Which answer best explains the GIL's practical impact?
Option B is strongest: it explains why the GIL exists (reference counting protection), precisely states when threads do work (GIL released during syscalls and C extension I/O), explains why threading fails for CPU-bound (bytecode not parallel), gives all three solutions with trade-offs (multiprocessing: memory/IPC cost; asyncio: single-thread; C extensions: GIL release during compute), and mentions the forward-looking Python 3.13 no-GIL build (PEP 703) — showing current awareness. Key structure: GIL exists for reference counting → threading works for I/O (GIL released in syscalls) → threading fails for CPU → multiprocessing solution + trade-offs → asyncio alternative → C extension GIL release → PEP 703 outlook. Option C is accurate but does not explain why the GIL exists or the IPC cost of multiprocessing. Option D mentions PyPy incorrectly — PyPy has its own GIL.
3 / 10
The interviewer asks: "How does dependency injection work in FastAPI, and why is it useful?" Which answer best explains FastAPI's DI system?
Option B is strongest: it explains the mechanism (signature inspection + recursive resolution), introduces the dependency tree concept, gives three concrete benefits with implementation specifics (generator with finally for DB sessions, auth injection, dependency_overrides for testing), mentions the lifespan context manager as the modern startup/shutdown pattern, and notes the async/sync handling difference (sync runs in thread pool). Key structure: Depends + signature inspection → recursive dependency tree → shared resources via generator → security injection → testability via overrides → lifespan for connection pools → async/sync auto-handling. Option C is accurate and mentions generator dependencies but misses the dependency tree, lifespan, and the async/sync distinction. Option D is too vague — does not explain generator dependencies or the override mechanism.
4 / 10
The interviewer asks: "How do you use type hints in Python, and what tools enforce them?" Which answer best demonstrates typing discipline?
Option B is strongest: it correctly states that the runtime ignores annotations (a common misconception — type hints are not enforced at runtime by default), distinguishes mypy vs pyright (noting pyright is stricter), explains TypeVar with a concrete use case, explains Protocol vs ABC for dependency inversion (a senior-level concept), explains Annotated with real framework examples (FastAPI, Pydantic), and mentions the Python 3.12 type parameter syntax improvement. Key structure: gradual typing: runtime ignores → mypy vs pyright → TypeVar for generics → Protocol for structural subtyping → Annotated for framework metadata → TypedDict/dataclasses → CI enforcement → 3.12 syntax improvement. Option C is accurate but treats Optional as a separate concept (it is just Union with None in modern Python) and does not explain Protocol. Option D recommends typing "at minimum function signatures" which is good advice but does not explain the Annotated pattern or gradual typing mechanics.
5 / 10
The interviewer asks: "What are the common pitfalls with SQLAlchemy ORM, and how do you handle the N+1 query problem?" Which answer best explains ORM query patterns?
Option B is strongest: it precisely defines N+1 as replacing a JOIN with N round trips (not just "one query per item"), explains why joinedload vs selectinload are appropriate in different cases (JOIN vs IN clause, duplicate row risk for one-to-many), explains DetachedInstanceError from session mismanagement, explains why async disables lazy loading by default (event loop blocking — not just "not supported"), and introduces bulk operations as a separate performance pattern. Key structure: N+1 = N round trips replacing one JOIN → joinedload (JOIN) vs selectinload (IN clause, one-to-many) → session lifecycle and DetachedInstanceError → async disables lazy loading to prevent event loop blocking → bulk operations for mass inserts. Option C is accurate and gives the async reason but does not explain why selectinload is preferred for one-to-many or mention DetachedInstanceError. Option D does not explain the JOIN vs IN clause distinction or session lifecycle errors.
6 / 10
Alex from the QA team just left a comment on your PR:
'I'm seeing intermittent failures with this endpoint when simulating high traffic. The response times are spiking significantly, and I've observed occasional 502 errors. Can you investigate the database queries involved?'
Which of the following responses best addresses Alex's concerns?
The key here is proactive troubleshooting. Simply stating that you've optimized the code isn't sufficient – QA needs demonstrable evidence of improvement and understanding of the problem. Option 4 demonstrates a systematic approach by adding logging to identify bottlenecks, aligning with best practices for debugging performance issues. Options A and B are evasive or dismissive.
7 / 10
During a daily standup meeting, your team lead asks: 'What progress have you made on implementing the new user authentication flow?'
You reply:
'I've finished the API endpoint for creating new users and implemented basic validation. I'm still working on integrating with the existing database schema.'
Which of the following statements best reflects a clear and informative update?
The best response provides specific details about what you *have* accomplished. Option 2 clearly outlines your progress and acknowledges ongoing work. Options A is overly optimistic and lacks specifics, B is too vague, and C shifts the focus inappropriately.
8 / 10
You're receiving an API response from a third-party service:
```json
{
"status": "error",
"code": 400,
"message": "Invalid request parameters.",
"details": [
"Parameter 'email' is missing.",
"Parameter 'password' is not a valid email address."]
}
```
Which action should you take next?
The response clearly indicates an issue with the input data. Option 2 directly addresses this by correcting the parameters. Ignoring the error (A), contacting support immediately (C) without investigation, or logging alone (D) are insufficient steps—you need to fix the underlying problem. This demonstrates understanding of API responses and debugging.
9 / 10
You're reviewing a PR introducing a new feature that uses FastAPI. The code includes this snippet:
```python
from fastapi import Depends, FastAPI, Request
from typing import Optional
app = FastAPI()
def get_request(request: Request):
return request
@app.get('/data')
def data():
return {"message": "Hello"}
```
The reviewer comments: 'How does this code use dependency injection?'
Which of the following explanations is most accurate?
This is the fundamental concept of dependency injection. While the provided example is simple, the comment highlights that DI allows passing objects into functions rather than creating them internally – this enables flexibility and testability. Options B and D are too abstract or incorrect, and C misrepresents the code's use.
10 / 10
You're designing a database schema for an e-commerce platform. You need to store product information, including its name, description, price, and category. Using SQLAlchemy, you've created the following model:
```python
from sqlalchemy import Column, Integer, String
class Product(Base):
__tablename__ = 'products'
id = Column(Integer, primary_key=True)
name = Column(String)
description = Column(String)
price = Column(Integer)
category_id = Column(Integer, ForeignKey("categories".id))
```
You realize you're getting a 'N+1' query problem when listing all products in a category. What is the root cause of this issue?
The 'N+1' problem arises when an ORM makes a separate query for each item in a collection. In this case, fetching all products triggers one query to get product data, and then *one additional query for each product* to retrieve its category information – hence N+1. Options A is incorrect; B accurately describes the root cause, C misattributes the issue to the constraint, and D focuses on indexing which isn't the core problem.
What does "Python Backend Developer Interview Questions — Best-Answer Practice" cover?
Practice answering Python Backend Developer interview questions in professional English. 5 exercises covering asyncio, GIL, FastAPI, type hints, and SQLAlchemy.
How many questions are in this interview set?
This set has 10 exercises, each with a full explanation.
Is this exercise free to use?
Yes. Every exercise on CoderSlingo, including this one, is free to use with no account, sign-up, or paywall.
Do these exercises include model answers?
Yes. Each interview question gives you several possible responses and asks you to pick the one that communicates most clearly and completely — the explanation then breaks down exactly why that answer works, including the specific vocabulary a strong candidate would use.
What if I choose an answer that isn't the strongest one?
You'll see which option was correct and read a full explanation of why it's stronger than the alternatives, plus the key vocabulary and phrasing worth reusing in a real interview.
Can I retry the questions?
Yes — use the "Try again" button on the results screen to reset and go through the set again.
Is this the same as a real technical or behavioural interview?
No — it's focused practice for the language side of interviewing: recognising which phrasing sounds precise and confident versus vague, and knowing the vocabulary interviewers expect for this role. It won't replace mock interviews, but it builds the vocabulary you'll need in one.
Where can I find interview prep for other roles?
Browse the full Interview exercises hub for 170+ modules covering behavioural, technical, and system design rounds across dozens of IT roles, or check the "Next up" link below to continue.
Do I need an account, and is my progress saved?
No account is needed. Progress is tracked only for your current visit — reloading or leaving the page resets the counter.
Who writes these interview questions?
Every question is written by the CoderSlingo team based on real technical interview patterns for this role, then reviewed for accuracy and clarity.