Python interview questions and answers for freshers
By Vikram · Updated 26 Oct 2026
Python interviews for freshers mix concept questions with “what is the output?” snippets that test how the language really behaves. These are the questions that come up most, with the answer you should be able to give in a sentence or two.
Core concepts
- List vs tuple: lists are mutable, tuples are immutable. Tuples of hashable items can be dictionary keys or set members.
- Mutable vs immutable types: list, dict and set are mutable; int, float, str, tuple and frozenset are immutable.
- is vs ==: == compares values, is checks whether two names point to the same object. Use is only for None.
- Shallow vs deep copy: a[:] or copy.copy() copies the outer container only; copy.deepcopy() copies nested objects too.
- // vs /: // is floor division; / always returns a float in Python 3.
- Variable arguments: *args collects extra positional arguments as a tuple, and the double-star kwargs parameter collects extra keyword arguments as a dict.
Gotchas interviewers love
- Mutable default arguments: def add(x, box=[]) shares one list across every call, because defaults are evaluated once. Use box=None.
- Late-binding closures: [lambda: i for i in range(3)] all return 2. Bind the value with lambda i=i: i.
- List multiplication: [[0] * 2] * 2 creates two references to the same inner list.
- Floating point: 0.1 + 0.2 == 0.3 is False. Compare with math.isclose().
- Class vs instance attributes: self.count += 1 creates an instance attribute and leaves the class attribute unchanged.
Advanced questions
- Generators: functions with yield produce values lazily, one at a time, which saves memory on large data.
- Decorators: functions that take a function and return a wrapped one; stacked decorators apply bottom-up.
- The GIL: in CPython only one thread runs Python bytecode at a time. Threads still help with I/O; use multiprocessing for CPU-bound work.
- MRO: with multiple inheritance, super() follows the method resolution order (C3 linearisation), not just the parent class.
- Context managers: with blocks call __enter__ and __exit__, so files and locks are always released.
Tip: Output questions are the fastest way to find gaps. The Python questions with answers page has every Python question from the Daily Quiz, with explanations.
Frequently asked questions
What is the difference between a list and a tuple in Python?
A list is mutable and a tuple is immutable. Tuples are slightly faster and can be used as dictionary keys when their items are hashable.
Why are mutable default arguments a problem in Python?
Default values are created once, when the function is defined, so a default list or dict is shared by every call. Use None and create the object inside the function.
What is a generator in Python?
A function that uses yield to produce values one at a time, pausing between them. It is memory-efficient for large or infinite sequences.
What is the GIL?
The Global Interpreter Lock in CPython lets only one thread execute Python bytecode at a time. It is released during blocking I/O, so threads help for I/O-bound work but not CPU-bound work.