Interview questionsUpdated 12 Oct 2026 · Team InterviewPlan

Python Developer Interview Questions and Answers

Python developer interviews test whether you understand the language beyond syntax: how memory and mutability work, when to use generators or async, and how you build and test real APIs. These questions reflect what backend, automation and data platform teams ask Python candidates in 2026.

What interviewers test in a Python developer interview

Python roles vary widely: web backends with Django or FastAPI, automation and scripting, data pipelines and ML platform work. Most loops still include a language fundamentals round, a coding round and a framework or project round.

Interviewers look for clean, Pythonic code and a clear understanding of trade-offs, such as when concurrency helps and when it does not.

  • Language: data types, mutability, scope, closures and dunder methods
  • Advanced features: generators, decorators, context managers and typing
  • Concurrency: GIL, threads, processes and asyncio
  • Frameworks: Django ORM, Django REST Framework, FastAPI and Pydantic
  • Quality: pytest, mocking, linting and type checking

Technical topics to revise

Build and run small examples for every topic. Interviewers often ask you to predict output, such as what a function with a mutable default argument returns on the second call.

  • Lists, tuples, sets, dicts and their time complexities
  • Shallow versus deep copy and object identity with is
  • Generators, yield, itertools and memory-efficient processing
  • Decorators with functools.wraps and decorators that take arguments
  • asyncio event loop, async and await, and aiohttp or httpx
  • Django ORM select_related, prefetch_related and migrations
  • FastAPI dependency injection, Pydantic models and background tasks
  • pytest fixtures, parametrize, monkeypatch and coverage

How to structure your answers

Explain the concept in one sentence, show a tiny example and then mention a real situation where it mattered. For coding questions, write readable code first, then discuss complexity and how you would optimise.

For project questions, name the stack, the scale and your exact contribution. Numbers such as requests per second or job run time make your answer credible.

How InterviewPlan AI helps you prepare

Practise Python mock interviews with fundamentals, coding and framework questions, and use coding help to review practice solutions. Resume AI helps you show impact from scripts and services you built.

During live interviews, Interview Copilot gives real-time transcription with speaker labels and resume-based answer drafts on Zoom, Teams, Meet and Webex. Python Job Support then helps in your first 90 days on the job. Copilot and Job Support are $5 per hour and hours never expire.

Questions and model answers

9 questions you are likely to hear.

  1. What is the difference between a list and a tuple, and when would you use each?

    Why they ask: This fundamentals question tests mutability and practical design choices.

    Sample answer: A list is mutable, so I can append, remove and change items, while a tuple is immutable once created. Tuples are slightly more memory efficient, can be used as dictionary keys if their contents are hashable, and signal that the data should not change, like a coordinate pair or a database row. I use lists for collections that grow or change, such as records being processed. In one ETL script I used tuples as composite keys in a dictionary to deduplicate records by customer ID and date, which was simpler and faster than building string keys.

  2. What happens when you use a mutable default argument in a function?

    Why they ask: This classic gotcha tests understanding of how Python evaluates function definitions.

    Sample answer: Default argument values are evaluated once, when the function is defined, not each time it is called. So if I write def add_item(item, items=[]), the same list is shared across calls and keeps growing. The safe pattern is to default to None and create a new list inside the function when items is None. I found this bug in a Flask service where a helper function accumulated user permissions across requests, so some users saw options they should not have. It only appeared under load, which made it hard to spot until I read the function signature carefully.

  3. Explain generators and why you would use them.

    Why they ask: Generators show whether you can write memory-efficient code for real data volumes.

    Sample answer: A generator is a function that uses yield to produce values one at a time, pausing its state between calls instead of building the whole result in memory. Generator expressions work the same way with parentheses. I use them for streaming large files, paginated API results or database cursors. In a log processing job, reading a 6 GB file into a list caused memory errors, so I rewrote it as a generator pipeline: read lines, parse, filter and aggregate. Memory stayed under 200 MB and the job ran on a small container without any other changes.

  4. What is the GIL, and how does it affect threading?

    Why they ask: Interviewers check whether you choose the right concurrency model.

    Sample answer: The Global Interpreter Lock in CPython allows only one thread to execute Python bytecode at a time. That means threads do not speed up CPU-bound work, but they do help I/O-bound work because the GIL is released while waiting on network or disk. For CPU-heavy tasks I use multiprocessing or concurrent.futures ProcessPoolExecutor, or push work into libraries like NumPy that release the GIL. Python 3.13 introduced an experimental free-threaded build, but most production systems still use the standard build. For an image processing task, switching from threads to processes cut run time by about 70 percent on an 8-core machine.

  5. How do decorators work? Write one that logs execution time.

    Why they ask: Decorators test understanding of functions as first-class objects and closures.

    Sample answer: A decorator is a function that takes a function and returns a new function that wraps it. For a timer, I define timed(func), and inside it a wrapper that takes *args and **kwargs, records time.perf_counter before and after calling func, logs the difference with the function name and returns the result. I decorate the wrapper with functools.wraps so the original name and docstring are preserved. I have used this pattern in a FastAPI service to measure slow external calls, which helped us find a vendor API that was adding over a second to some requests.

  6. When would you use asyncio, and what are its pitfalls?

    Why they ask: Async is common in modern Python APIs, and misuse causes subtle performance bugs.

    Sample answer: I use asyncio for I/O-bound workloads with many concurrent operations, such as calling multiple APIs or handling many websocket connections. With async and await, one thread can handle thousands of waiting tasks. The main pitfall is calling blocking code inside async functions, such as the requests library or a synchronous database driver, which blocks the whole event loop. I use httpx or aiohttp and async drivers, or run blocking calls in a thread with asyncio.to_thread. In one FastAPI service, replacing requests with httpx in async endpoints roughly tripled throughput under load testing.

  7. How do you avoid N+1 queries in the Django ORM?

    Why they ask: This tests practical framework performance knowledge.

    Sample answer: N+1 happens when I loop over a queryset and access a related object, causing one extra query per row. For foreign key and one-to-one relations I use select_related, which does a SQL join. For many-to-many and reverse relations I use prefetch_related, which runs a second query and joins in Python. I detect the problem with Django Debug Toolbar or by counting queries in tests with assertNumQueries. On an admin page listing orders with customer and product details, adding select_related and prefetch_related cut queries from over 300 to 3 and the page loaded in well under a second.

  8. How do you structure tests for a Python API?

    Why they ask: Interviewers want evidence that you write maintainable, reliable code.

    Sample answer: I use pytest with fixtures for shared setup, like a test client and a test database, and parametrize to cover multiple inputs without repeating code. Unit tests cover business logic with external services mocked, using monkeypatch or unittest.mock. Integration tests hit the API through the framework's test client against a real database in a container. I keep tests fast so they run on every commit in CI. In my last team, adding API tests for the top ten endpoints before a refactor caught several breaking changes and let us ship the refactor without any production incidents.

  9. Tell me about a Python script or service that saved your team significant time.

    Why they ask: This shows practical impact and ownership.

    Sample answer: Our support team at a SaaS company manually reconciled payment records between Stripe exports and our database every week, which took about a day. I wrote a Python job using pandas to pull both sources, match on payment IDs, flag mismatches by type and post a summary to Slack. I added tests for the matching rules and scheduled it with a cron job in our Kubernetes cluster. The weekly work dropped to around 30 minutes of reviewing exceptions, and it caught a refund sync bug that had been silently failing for weeks.

FAQ

Questions people ask about python developer.

Should I learn Django or FastAPI for Python interviews?

Learn the one in the job description first. Django is common for full web applications with admin and ORM needs, while FastAPI is popular for APIs and ML services. Knowing the core ideas of both, such as ORM performance and request validation, helps in most interviews.

What coding topics come up in Python interviews?

Strings, lists, dictionaries, sets, sorting and searching, recursion and common patterns like two pointers and sliding windows. Some teams add practical tasks such as parsing a log file or calling an API and handling errors.

Are Python interviews different for data roles?

Yes. Data engineering and data science roles focus more on pandas, SQL, PySpark and data processing patterns, while backend roles focus on web frameworks, APIs and concurrency. Read the job description and weight your preparation accordingly.

Does InterviewPlan AI support Python technical interviews?

Yes. You can practise Python mock interviews and use coding help with AI credits, and use Interview Copilot live on the Windows or macOS desktop app. Always follow the employer's rules for coding assessments.

P.S.

Reading helps. Practising out loud helps more.

Start free with 5 live minutes and 100 AI credits for Resume AI, Job Search, Auto-Apply, mock interviews and Behavioral Coach.