Python Developer interview questions and answers
Python developer interviews cover the language itself (data types, functions, OOP, generators), a web framework such as Django, FastAPI or Flask, testing, and often scripting or data tasks. Expect a live coding exercise.
Skills and knowledge
What is the difference between a list and a tuple?
Sample answer: A list is mutable, so you can add, remove and change items; a tuple is immutable once created. Tuples are slightly faster, can be used as dictionary keys and signal that the data should not change, such as coordinates. Lists suit collections that grow or change.
What are decorators?
Sample answer: A decorator is a function that takes another function and returns a new one that adds behaviour, applied with the @ syntax. Common uses are logging, timing, caching (functools.lru_cache), access checks and routes in web frameworks. Use functools.wraps so the decorated function keeps its name and docs.
What are generators and why use them?
Sample answer: A generator is a function that uses yield to produce values one at a time instead of building a full list. It saves memory and can handle very large or endless data, such as reading a huge file line by line. Generator expressions look like list comprehensions with round brackets.
What is the GIL?
Sample answer: The global interpreter lock in standard CPython lets only one thread run Python code at a time. Threads still help for waiting on network or disk, but for CPU-heavy work you use multiprocessing, native libraries such as NumPy that release the lock, or newer free-threaded builds. Async code helps with many concurrent network calls.
How is memory managed in Python?
Sample answer: Python counts references to each object and frees it when the count reaches zero, with a garbage collector that also cleans up reference cycles. You rarely manage memory directly, but large objects held in global variables or caches can still cause memory to grow.
What is the difference between deep copy and shallow copy?
Sample answer: A shallow copy creates a new outer object but shares the inner objects, so changing a nested list affects both. A deep copy, from copy.deepcopy, copies everything recursively so the two are fully independent. Assignment with = copies nothing; it just creates another name for the same object.
Django, Flask or FastAPI: how do you choose?
Sample answer: Django includes an ORM, admin panel, auth and many features, ideal for full web apps built quickly. Flask is minimal and flexible for small services. FastAPI is modern and fast, with async support, automatic validation from type hints and API docs, which makes it popular for APIs and ML services.
How do you manage dependencies in a Python project?
Sample answer: Use a virtual environment per project, declare dependencies in pyproject.toml or requirements files, pin exact versions with a lock file using tools such as pip-tools, Poetry or uv, and update regularly with tests to catch breaking changes. Never install project packages into the system Python.
How do you test Python code?
Sample answer: Use pytest with small, focused tests, fixtures for setup, parametrize for many inputs and mocks for external services. Run tests in CI on every change, measure coverage on important code, and add type checking with mypy or pyright and a linter such as ruff.
Past experience
Tell me about a script or tool you wrote that helped others.
Sample answer: Explain the manual problem, what your script automated (reports, data cleaning, deployments), how you made it reliable and easy to use, and the time or errors it saved. Small automation wins are valued highly.
What would you do?
A Python job that processes a big file runs out of memory. How do you fix it?
Sample answer: Stop loading the whole file at once: read it line by line or in chunks with a generator or pandas chunksize, write results as you go, use more compact data types, and process in parallel batches if needed. Measure memory before and after to confirm.
An API built in Python is slow. Where do you look first?
Sample answer: Measure first with logging, profiling or tracing to find which endpoint and which step is slow. Usually it is the database (missing indexes, N+1 queries) or calls to other services, not Python itself. Fix those, add caching, use async for many network calls, and only then optimise Python code.
Open Python Developer jobs
Remote · Brazil
Desenvolvedor de Software Junior
Remote · Brazil
ANALISTA DE WEB ANALYTICS SR
Remote · Portugal
Senior Developer
Remote · Worldwide
Lead Software Engineer - Alti (AI)
Remote · Worldwide
Senior Site Reliability Engineer, Konnect
Remote · United Kingdom