Skip to content
PPreptima

Python interview questions

Python for backend, automation, and data roles, including the runtime behaviour that surprises candidates who only know the syntax.

12 published across 7 topics.

Python fundamentals60 short answers on one page, for revising rather than studying.

Core Python

2 questions

Data model, mutability, scoping, comprehensions, and the truthiness and copying gotchas.

OOP in Python

2 questions

Dunder methods, MRO and multiple inheritance, descriptors, dataclasses, and properties.

mediumConceptCoding

If you were writing a small value type in Python, which dunder methods would you implement, what would you let a dataclass generate, and how does super() decide what to call?

Implement the dunders that opt your type into a protocol, treating repr, eq and hash as one decision, and let a dataclass generate the boilerplate when the fields are the identity. super() follows the C3 linearisation of type(self), so it calls the next class in the MRO rather than your own base.

4 minmid, senior
hardConceptCoding

What is a descriptor, and how does @property use one?

A descriptor is a class attribute defining __get__, and optionally __set__ or __delete__, that intercepts attribute access on instances. property is one. Whether it defines __set__ decides whether it beats the instance dictionary, which is the whole of attribute-lookup precedence.

5 minmid, senior, staff

Decorators, Generators & Iterators

1 question

Closures, laziness, context managers, and writing composable higher-order utilities.

mediumConceptCoding

How do generators reduce memory use, and when are they the wrong choice?

A generator produces items on demand and keeps only the current item plus its suspended frame, so memory stays flat as the input grows; it is the wrong tool when you need a length, indexing, or more than one pass, and when per-item resume overhead outweighs the space saved.

4 minmid, senior, staff

Concurrency & the GIL

2 questions

Threads versus processes versus asyncio, what the GIL actually blocks, and choosing per workload.

Python Memory & Performance

1 question

Reference counting, garbage collection, profiling, and where interpreter overhead dominates.

Django & FastAPI

2 questions

ORM behaviour and N+1, middleware, dependency injection, async endpoints, and validation.

Testing in Python

2 questions

pytest fixtures and parametrisation, mocking and patching boundaries, and coverage honestly read.