Python Developer Interview Guide

Python Interview Questions

Practice and screen Python developers with questions covering data structures, async programming, frameworks, testing, and production debugging.

A strong Python interview should test more than syntax. Good candidates explain trade-offs around memory, concurrency, framework behavior, package boundaries, and testability. Use these prompts to separate script familiarity from production engineering judgment.

Book A Demo
Section 1

Data Structures

Evaluate how candidates choose between lists, dicts, sets, tuples, heaps, and generators under real constraints.

1. You receive a stream of events and need to return the top 10 most frequent event types every minute. How would you design this in Python?

Interview prompt

Strong signal

Looks for Counter or heap usage, streaming trade-offs, memory bounds, and update complexity.

Follow-up probes

  • How would this change if the stream is too large for memory?
  • What would you test first?

Red flags

  • Sorts the full dataset every time without discussing cost.
  • Ignores memory growth or late-arriving events.

2. When would you use a generator instead of returning a list?

Interview prompt

Strong signal

Understands lazy evaluation, memory use, one-pass iteration, and pipeline composition.

Follow-up probes

  • What bugs can generators introduce?
  • How do you debug a generator pipeline?

Red flags

  • Only says generators are faster.
  • Cannot explain exhaustion or side effects.
Section 2

AsyncIO

Check whether candidates understand cooperative concurrency, event loops, and I/O-bound workloads.

1. Explain what happens when an async function awaits a network request. What is the event loop doing?

Interview prompt

Strong signal

Can explain suspension, scheduling, non-blocking I/O, and why CPU-heavy work blocks the loop.

Follow-up probes

  • Where would you use a thread pool?
  • How do you handle cancellation?

Red flags

  • Confuses async with parallel CPU execution.
  • Cannot explain blocking calls inside async code.

2. You have 5,000 URLs to fetch with rate limits. How would you structure the code?

Interview prompt

Strong signal

Mentions semaphores, backoff, timeouts, retries, and observability.

Follow-up probes

  • How would you prevent one slow request from stalling the batch?
  • How would you test this?

Red flags

  • Uses gather without limits.
  • No timeout, retry, or error strategy.
Section 3

Django and Flask

Test practical web framework judgment, ORM behavior, request lifecycle, and maintainability.

1. A Django endpoint is slow after adding a list page. How would you investigate and fix it?

Interview prompt

Strong signal

Looks for query inspection, select_related/prefetch_related, pagination, caching, and measurement.

Follow-up probes

  • How do you avoid N+1 queries?
  • Where would you add caching?

Red flags

  • Adds indexes blindly.
  • Does not inspect SQL or request timing.

2. When would you choose Flask over Django for a production service?

Interview prompt

Strong signal

Understands framework scope, team needs, admin/ORM requirements, and operational complexity.

Follow-up probes

  • What would you need to add around Flask?
  • How do you keep a Flask app organized as it grows?

Red flags

  • Frames one framework as always better.
  • Ignores auth, migrations, or structure.
Section 4

Testing

Measure whether candidates can write maintainable tests around behavior, integrations, and failures.

1. How would you test a function that calls a third-party API and writes results to Postgres?

Interview prompt

Strong signal

Mentions unit boundaries, mocks/fakes, integration tests, fixtures, transactions, and failure cases.

Follow-up probes

  • What belongs in a unit test vs integration test?
  • How do you avoid flaky tests?

Red flags

  • Only tests the happy path.
  • Mocks so much that behavior is no longer meaningful.
Section 5

Production Debugging

Separate candidates who can ship from those who only solve isolated coding exercises.

1. A Python worker's memory grows all day and resets after restart. How do you debug it?

Interview prompt

Strong signal

Looks for profiling, object retention, queues, caches, file handles, and deployment observability.

Follow-up probes

  • Which metrics would you add?
  • How do you prove the fix worked?

Red flags

  • Immediately blames Python or the GC.
  • No measurement plan.

Hire better with structured interviews

Access our full question library and automate your evaluation workflow today.