Python Developer Technical Questions Interview Questions
10 curated questions with evaluation guidance for hiring managers.
Explain the difference between lists, tuples, and sets in Python. When would you use each?
Should cover mutability (list mutable, tuple immutable), ordering (list, tuple ordered; set unordered), duplicates (set unique), and performance (set for membership tests). Look for practical decision-making.
How do decorators work in Python? Write an example of a logging or timing decorator.
Should explain that decorators wrap functions, show understanding of *args/**kwargs, functools.wraps for preserving metadata, and practical use cases. Look for clear code examples.
Explain generators and the yield keyword. When would you use a generator instead of returning a list?
Should explain lazy evaluation, memory efficiency for large datasets, iterator protocol, and practical use cases (reading large files, infinite sequences). Look for understanding of memory implications.
How does Python's asyncio work? What is the difference between concurrency and parallelism in Python?
Should explain event loop, coroutines (async/await), the GIL limitation for CPU-bound tasks, and when asyncio is beneficial (I/O-bound). Look for practical async patterns.
Explain Python's Global Interpreter Lock (GIL). How do you work around it for CPU-bound tasks?
Should explain GIL limits true parallelism in CPython, mention multiprocessing, C extensions, or alternative implementations. Look for understanding of practical implications for web servers.
How do you manage dependencies and virtual environments in Python projects?
Should discuss venv, pip, requirements.txt, Poetry/Pipenv, and importance of reproducible environments. Look for professional experience with dependency management.
Explain the difference between __new__ and __init__ in Python. When would you override __new__?
Should explain __new__ creates the instance, __init__ initializes it. Should mention singleton pattern, immutable type subclassing. Look for advanced Python knowledge.
How do you handle errors in Python? What is your approach to exception handling in production code?
Should discuss specific vs. generic exceptions, custom exception hierarchies, logging, not swallowing exceptions silently, and the ask for forgiveness (EAFP) pattern. Look for production-grade error handling.
What are Python metaclasses? When have you used them or when would you use them?
Should explain metaclasses control class creation, mention practical uses (ORM, validation frameworks). Look for awareness that metaclasses are usually overkill and should be used sparingly.
How do you optimize Python code performance? Walk me through your approach.
Should discuss profiling first (cProfile), then algorithmic improvements, then micro-optimizations (comprehensions, local variables), then C extensions if needed. Look for data-driven optimization.
Want AI-generated interview questions tailored to your specific job description? Workro analyses your JD and generates behavioural and technical questions calibrated for the role, seniority level, and required skills — in seconds.
Try free