Python shows up everywhere now — backend, data, ML, automation, and most India fresher hiring. Its interviews reward knowing the language's behavior, not just its syntax, because Python has a handful of famous gotchas interviewers love. Here are the Python interview questions that actually get asked, with answers.
Core Python
- Mutable vs immutable types — list/dict/set vs tuple/str/int.
- List vs tuple vs set vs dictionary — when to use each.
- What is
*argsand**kwargs? - Shallow copy vs deep copy.
- How does Python manage memory and garbage collection (reference counting)?
The famous gotchas
- Mutable default arguments — why
def f(x=[])is a trap. - is vs == — identity vs equality, and small-integer caching.
- Why
0.1 + 0.2 != 0.3(floating point). - Late binding in closures and loops.
Intermediate concepts
- List comprehensions and generator expressions — and when generators save memory.
- Decorators — what they are and a real use case.
- Generators and the
yieldkeyword. - The Global Interpreter Lock (GIL) and what it means for threads vs processes.
__init__vs__new__; dunder methods.
How to prepare
Many Python rounds are live and verbal — you explain what a snippet does and why. Practise articulating behavior out loud. Greenroom runs spoken technical interviews that probe your reasoning and give feedback on clarity. Pair it with our data structures and SQL guides.
Frequently asked questions
What are the most common Python interview questions?
Common Python questions cover mutable vs immutable types, list/tuple/set/dictionary differences, *args and **kwargs, shallow vs deep copy, memory management and reference counting, the famous gotchas (mutable default arguments, is vs ==, floating-point precision), and intermediate topics like decorators, generators, comprehensions and the GIL.
Why are mutable default arguments a problem in Python?
A default argument is evaluated once when the function is defined, not each time it's called. So a mutable default like def f(x=[]) shares the same list across all calls — appending to it in one call persists into the next. The fix is to default to None and create a fresh list inside the function.
What is the GIL in Python?
The Global Interpreter Lock is a mutex that allows only one thread to execute Python bytecode at a time within a process. It means CPU-bound multithreading doesn't achieve true parallelism in CPython, so you use multiprocessing for CPU-bound work and threads or async mainly for I/O-bound work.
How should I prepare for a Python interview?
Focus on understanding Python's behavior — mutability, the gotchas, generators, decorators and the GIL — not just syntax, since interviewers ask why a snippet behaves a certain way. Then practise explaining that behavior out loud, ideally with a voice-based mock interview that probes your reasoning, because many Python rounds are live and verbal.