Skip to main content
HireStepX is now in Beta! Be among the first to practice smarter and land your dream role.
Interview Skills

Python Developer Interview Questions India 2026: Django

Core Python (OOP, generators, decorators, GIL), Django/Flask, DSA, and system design questions at Indian product companies and FAANG India.

Interview Skills29 July 202614 min read read4 sections

Python is the dominant language for data engineering, ML engineering, and backend development at Indian product companies and startups. Whether you are applying as a Python backend engineer (Django, FastAPI), a data scientist, or an ML engineer, the interview covers overlapping but distinct territory. This guide covers the core Python concepts (OOP, generators, decorators, GIL, async), the Django and Flask questions asked at most Indian companies, and the coding questions interviewers actually use.

4 sections

Six core areas(1) OOP: classes, inheritance, MRO (C3 linearisation for multiple inheritance), dunder methods (__init__, __str__, __repr__, __len__, __eq__, __enter__, __exit__). (2) Generators and iterators: generators use yield; produce values lazily on demand instead of materialising all values in memory. Generator expressions vs list comprehensions: (x*2 for x in range(1000)) is memory-efficient; [x*2 for x in range(1000)] allocates immediately. (3) Decorators: a function that wraps another function, returning a new function with the same signature (use functools.wraps to preserve metadata). Common patterns: logging, authentication, rate limiting, caching. (4) Context managers: the with statement; implement via __enter__/__exit__ or @contextlib.contextmanager. Guarantees cleanup even on exceptions. (5) GIL: CPython's Global Interpreter Lock prevents true parallel CPU execution on multiple threads. For CPU-bound work use multiprocessing; for I/O-bound work use threading or asyncio. (6) Python memory model: mutable vs immutable (lists are mutable: modifying them in a function affects the caller's reference; integers and strings are immutable).

Django ORMselect_related performs a SQL JOIN for ForeignKey/OneToOne, fetching the related object in one query. prefetch_related performs a separate query for ManyToMany or reverse FK and does Python-level joining, better when the related set is large or has many-to-many. N+1 problem: accessing a related object inside a loop without select_related causes one query per iteration.

Django REST Frameworkserializers (model-to-JSON conversion with validation), ViewSets (combines list, retrieve, create, update, destroy into one class), authentication (SessionAuthentication, TokenAuthentication, JWTAuthentication), permissions (IsAuthenticated, IsAdminUser, custom permission classes).

Flask vs Django decisionFlask is a microframework with no ORM, admin, or auth out of the box; choose it when you want full control over the stack or building a small API. Django provides these batteries included; choose it for applications that need admin, auth, and a full ORM without assembling them manually.

FastAPI questions (increasingly common at Indian startups): Pydantic for request/response validation, async endpoints with async def, dependency injection for database sessions and auth, OpenAPI schema auto-generation.

Common Python coding questions with solutions: (1) LRU Cache: use collections.OrderedDict with accessOrder semantics (move_to_end on get, popitem(last=False) to evict oldest). (2) Flatten nested list: recursive generator using 'yield from' for each nested element, or itertools.chain with isinstance checks. (3) Find k most frequent elements: Counter from collections; then heapq.nlargest(k, counter.items(), key=lambda x: x[1]) or bucket sort. (4) Reverse a linked list: iterate with prev=None, curr=head, nxt=None; at each step: nxt=curr.next, curr.next=prev, prev=curr, curr=nxt. (5) Group anagrams: iterate strings; for each string, sort its characters as the key in a defaultdict(list), append the string. Return the values.

Python-specific gotchas interviewers test: mutable default arguments (def f(x, lst=[]) is a bug: lst persists across calls; use lst=None then lst = [] inside), late binding in closures (lambda x=i: x is the fix for the classic closure-in-loop bug), is vs == (is compares identity, not equality; integer cache makes small integers (−128 to 256) share identity in CPython but this is an implementation detail).

Junior Python roles (0-2 years): Core syntax, OOP, list comprehensions, basic Django CRUD views, REST API consumption with requests library, SQL via ORM, pytest basics.

Mid-level Python roles (2-5 years): Decorators and context managers, generator patterns, Django ORM optimisation (select_related, prefetch_related, annotate, aggregate), DRF with JWT auth, Celery for background tasks, Redis for caching, async Python with asyncio or FastAPI, pytest fixtures and parameterised tests.

Senior Python roles (5+ years): Python internals (CPython vs PyPy, GIL implications, memory management), performance profiling (cProfile, memory_profiler, py-spy), concurrency (asyncio event loop internals, ProcessPoolExecutor for CPU-bound), system design (distributed task queues, idempotent Celery tasks, database connection pooling), architecture decisions (when to choose microservices vs monolith), mentoring signals.

Quick answers

Before you close this tab.

Core Python interview topics: OOP (MRO, dunder methods), generators and iterators (lazy vs eager evaluation), decorators (functools.wraps), context managers (__enter__/__exit__), GIL (CPython CPU-bound limitation), and memory model (mutable vs immutable objects). Each should be explained with a practical example.

Django: select_related vs prefetch_related (JOIN vs separate query, N+1 problem), DRF serializers and ViewSets, middleware, signals. Flask: Flask vs Django trade-offs, application context vs request context. FastAPI (increasingly common): Pydantic validation, async endpoints, dependency injection, OpenAPI auto-generation.

Common: LRU Cache (OrderedDict), flatten nested list (recursive generator), k most frequent elements (Counter + heapq), reverse linked list (prev/curr/nxt iteration), group anagrams (sorted string as key in defaultdict). Gotchas tested: mutable default arguments, late binding in closures, is vs == for identity vs equality.

Junior (0-2 years): core syntax, OOP, basic Django CRUD, REST APIs. Mid-level (2-5 years): ORM optimisation, async Python (asyncio, FastAPI), Celery, Redis, pytest. Senior (5+ years): Python internals, performance profiling, system design at scale, architecture decisions, mentoring signals.

Explore more

Continue reading

Practice

Know the answer. Now say it.

Practise Python developer interviews with HireStepX's AI voice interviewer. Get scored feedback on technical depth, communication clarity, and problem-solving approach. First 2 sessions free.