Interview questions
Python interview questions for freshers
Python fresher interviews have a well-worn core: data structures and their trade-offs, a handful of language features everyone lists on their resume, and one or two traps that reliably separate people who've written Python from people who've read about it.
The traps matter most. Interviewers know the standard answers are memorizable, so they probe one level down — and that level is where these notes focus. If you can explain the mutable default argument bug, you've proven more than ten definitions would.
Question 1
What's the difference between a list and a tuple?
Mutability is the headline — but the differentiating sentence is when it matters: tuples as dict keys, tuples for fixed records, lists for collections that grow. The follow-up is usually "why would immutability ever be useful?" — have that sentence ready.
Question 2
How does a dictionary work internally?
Hash table: keys are hashed to slots, giving average O(1) lookup. Mentioning why keys must be hashable (and therefore immutable) connects this question to the previous one — interviewers notice when your answers form a coherent model.
Question 3
What happens with a mutable default argument (def f(x, items=[]))?
The classic trap: the list is created once at function definition, so it's shared across calls and grows. Explain the fix (default to None, create inside) and you've demonstrated real Python experience in thirty seconds — this bug is rarely learned from a book.
Question 4
Explain list comprehensions — and when not to use one.
Show the syntax with a real example, then earn the point with the second half: nested or multi-condition comprehensions are less readable than a plain loop. Knowing a feature's limits signals more maturity than enthusiasm for it.
Question 5
What is the difference between == and is?
== compares values; is compares identity (same object in memory). Give the practical rule — use is only for None — and mention that small-integer caching makes is appear to work sometimes, which is exactly why it's a trap.
Question 6
What are *args and **kwargs?
Variable positional and keyword arguments. The follow-up is "when have you actually used them?" — a wrapper function or passing options through to another function are honest, everyday answers.
Question 7
What is a decorator?
A function that wraps another to extend its behavior without changing its code. Even if you've never written one, know what @-syntax is doing and name uses you've met: timing, logging, route registration in Flask.
Question 8
How does Python handle memory — what is garbage collection here?
Reference counting as the main mechanism, plus a cycle collector for objects that reference each other. Fresher-level depth is fine; claiming more than you have invites the follow-up that proves it.
Question 9
What is the GIL?
The Global Interpreter Lock: one thread executes Python bytecode at a time, so threads don't speed up CPU-bound work — use multiprocessing for that, threads for I/O-bound work. That one distinction is the entire expected answer.
Question 10
Write a function to count word frequency in a string.
The most common live-coding warmup: lowercase, split, count into a dict (or collections.Counter — mentioning it scores points). Narrate as you write; silent coding wastes the interview's real channel.
Common questions
How much Python is enough for a fresher interview?
Comfortable fluency with core data structures, functions, comprehensions, exceptions, and file handling — plus the standard traps (mutable defaults, == vs is). Frameworks are a bonus tied to your projects, not a requirement.
Will I have to write code live?
Usually yes — a short problem in a shared editor or on paper: string manipulation, dict counting, simple list logic. Practicing while explaining your thinking out loud is the underrated half of the preparation.
Python or Java for fresher placements?
Whichever your projects are actually in — depth in one beats surface in both, and interviews reward the language you can defend under follow-ups. Python's shorter syntax does make live-coding rounds slightly more forgiving.