Python Developer Interview Questions and Answers

Python interviews check that you understand how the language behaves, not just its syntax. Expect questions on data types, functions, OOP and performance, plus your framework (Django, Flask or FastAPI) for web roles.

Language fundamentals

List vs tuple?

Lists are mutable; tuples are immutable. Tuples can be used as dictionary keys (if their contents are hashable) and signal fixed data.

What are mutable default arguments, and why are they a problem?

Default values are evaluated once, when the function is defined. A default such as def f(x=[]) is shared across calls, so changes persist. Use None as the default and create the list inside the function.

What is the difference between a shallow and a deep copy?

A shallow copy creates a new container that holds references to the same inner objects. A deep copy (copy.deepcopy) recursively copies the inner objects too.

What are *args and **kwargs?

*args collects extra positional arguments into a tuple; **kwargs collects extra keyword arguments into a dict.

Intermediate topics

What is a decorator?

A function that takes a function and returns a new function that adds behaviour, such as logging, caching or access checks, without changing the original code. Applied with @decorator syntax.

What is a generator?

A function that uses yield to produce values lazily, one at a time, keeping its state between calls. It saves memory for large or infinite sequences.

What is the GIL?

In CPython, the Global Interpreter Lock lets only one thread execute Python bytecode at a time. Threads still help for I/O-bound work; for CPU-bound work, use multiprocessing or native extensions.

How does Python manage memory?

Mainly with reference counting, plus a cyclic garbage collector that cleans up reference cycles.

Web and data roles

Frequently asked questions

Are Python coding rounds different from other languages?

The problems are the same, but interviewers expect idiomatic Python: comprehensions, built-ins, and the right data structures.

Should I learn a framework for Python interviews?

For web roles, yes: know one of Django, Flask or FastAPI well, and explain a project you built with it.

Related guides