PUBLIC QUESTION PREVIEW
Python interview questions
Decorators, generators, GIL, async, Pythonic patterns, memory model.
Showing 12 of 100 source questions. Sample answers are study material, not employer-specific hiring guidance.
How to work through this preview
Attempt each question before reading its answer. For a concept, give a definition and a concrete example. For code, state constraints, walk through a small input, and check complexity. For design, separate requirements from assumptions and explain failure handling. Use real situations for behavioral answers.
QUESTION 1 / medium / coding
What is a decorator in Python? Write a simple timing decorator.
Sample answer
Hints to guide your next attempt
- A decorator is a function that wraps another function
- Use functools.wraps to preserve the original function's metadata
Source tags: decorator / functools / python / higher-order-function
QUESTION 2 / medium / conceptual
What is the GIL in Python? How does it affect multithreading?
Sample answer
Hints to guide your next attempt
- GIL = Global Interpreter Lock
- Only one thread executes Python bytecode at a time
Source tags: gil / threading / cpython / concurrency / python
QUESTION 3 / medium / conceptual
What is a generator in Python? How does yield work? When would you use one over a list?
Sample answer
Hints to guide your next attempt
- yield pauses function execution and returns a value
- Generators are lazy — they produce values on demand
Source tags: generator / yield / lazy-evaluation / memory / python
QUESTION 4 / easy / conceptual
What is the difference between deepcopy and shallow copy in Python?
Sample answer
Hints to guide your next attempt
- Shallow copy copies the container but not nested objects
- deepcopy recurses into all nested objects
Source tags: copy / deepcopy / reference / python
QUESTION 5 / easy / conceptual
What are *args and **kwargs in Python? Give an example.
Sample answer
Hints to guide your next attempt
- *args collects positional arguments as a tuple
- **kwargs collects keyword arguments as a dict
Source tags: args / kwargs / functions / python
QUESTION 6 / easy / conceptual
What is the difference between a list and a tuple in Python?
Sample answer
Hints to guide your next attempt
- Mutability is the key difference
- Tuples can be used as dict keys
Source tags: list / tuple / mutability / python / basics
QUESTION 7 / easy / conceptual
What are mutable and immutable types in Python? Give examples and explain the implications.
Sample answer
Hints to guide your next attempt
- Immutable: int, str, tuple, frozenset
- Mutable: list, dict, set
Source tags: mutable / immutable / python / types / basics
QUESTION 8 / easy / conceptual
What is the difference between "is" and "==" in Python?
Sample answer
Hints to guide your next attempt
- "is" checks identity (same object in memory)
- "==" checks equality (calls __eq__)
Source tags: is / equality / identity / python / gotcha
QUESTION 9 / easy / conceptual
What are comprehensions in Python? Show list, dict, set, and generator forms.
Sample answer
Hints to guide your next attempt
- [expr for item in iterable if condition]
- Generator comprehension uses () — lazy evaluation
Source tags: comprehension / generator-expression / python / basics
QUESTION 10 / easy / conceptual
What are lambda functions? When should and should not you use them?
Sample answer
Hints to guide your next attempt
- lambda args: expression — single expression only
- Good for sort keys, bad for complex logic
Source tags: lambda / anonymous-function / python / functional
QUESTION 11 / medium / conceptual
Explain Python's LEGB scoping rule with an example of global and nonlocal.
Sample answer
Hints to guide your next attempt
- LEGB = Local, Enclosing, Global, Built-in
- nonlocal lets nested functions write to enclosing scope
Source tags: legb / scope / global / nonlocal / python
QUESTION 12 / medium / conceptual
What is the mutable default argument bug in Python? How do you fix it?
Sample answer
Hints to guide your next attempt
- Default arguments are evaluated ONCE at function definition time
- Fix: use None as sentinel
Source tags: mutable-default / gotcha / python / bugs / functions
Check understanding, not recognition
- Can you explain the answer without reading it?
- Can you show when the approach fails or needs a different assumption?
- Can you connect the concept to a real project, task, or decision you have made?
- Can you distinguish a simplified interview example from a production requirement?
A LITTLE MORE CLARITY
Frequently asked questions
How many Python questions are shown here?
This public preview shows 12 questions with the supplied answers from the app's 100-question Python bank. Full interactive practice requires signing in.
Should I memorize the sample answers?
Use them as reference explanations, not a script or a guarantee of technical correctness for every environment. Explain your assumptions, validate code against your language and version, and discuss trade-offs. Behavioral answers should be built from your own experience.
What do hints and solution steps mean?
Hints identify ideas to consider before reading the answer. When the source question includes steps, they are shown as a separate walkthrough. Example capacities and design targets in a solution are assumptions for that exercise, not real system statistics.
BUILD YOUR NEXT OPPORTUNITY
Practice Python actively.
Sign in to use the full topic bank and interactive practice workspace.