The language, not just syntax

Python Interview Questions

Data models, generators, decorators, concurrency, packaging and the Python details that reveal real experience.

Quiz me
40 questions10 easy22 medium8 hard0/40 learned
01What is Python and what are its defining characteristics?Easypython · interpreter · dynamic typing02What are Python's core data types and how do they behave?Easytypes · immutability · builtins03When should you use a list versus a tuple?Easylists · tuples · immutability04How do Python dictionaries work and when do you use them?Easydict · hash table · lookup05How do sets work and when are they the right tool?Easysets · hashing · membership06Why does mutability matter in Python?Mediummutability · aliasing · defaults07How do list comprehensions work and when should you avoid them?Easycomprehensions · iteration · readability08How do generators work and why use them?Mediumgenerators · laziness · yield09What is the iterator protocol?Mediumiterators · protocols · for loops10How do decorators work and what are their pitfalls?Mediumdecorators · closures · functools11What is a context manager and how do you write one?Mediumcontext managers · with · cleanup12How should exceptions be handled in production Python?Mediumexceptions · error handling · eafp13How does object-oriented programming work in Python?Mediumoop · classes · methods14How does inheritance and the MRO work in Python?Mediuminheritance · mro · composition15Which dunder methods matter most and what contracts do they carry?Mediumdunder methods · protocols · operators16When should you use a dataclass?Mediumdataclasses · data modeling · boilerplate17How do type hints work in Python and what do they buy you?Mediumtype hints · mypy · typing18How do *args and **kwargs work?Easyfunctions · arguments · packing19How do closures work in Python?Mediumclosures · scope · nonlocal20When should you use a lambda?Easylambda · functions · style21How do map, filter and reduce compare with comprehensions?Mediumfunctional · map · reduce22Why use a virtual environment?Easyvenv · isolation · dependencies23How do modern Python packaging and dependency management work?Mediumpackaging · pip · pyproject24How does the Python import system work?Mediumimports · modules · packages25What is the GIL and what are its practical consequences?Hardgil · cpython · concurrency26When do you use threads, processes or asyncio?Hardconcurrency · threads · multiprocessing27How does asyncio work and where does it fail?Hardasyncio · event loop · coroutines28How does Python manage memory and how do you reduce usage?Hardmemory · reference counting · slots29How does Python's garbage collector handle cycles?Mediumgarbage collection · cycles · weakref30What is the difference between a shallow and a deep copy?Mediumcopy · aliasing · nested data31How should you format strings in modern Python?Easystrings · f-strings · formatting32How do you read and write files safely in Python?Mediumfile i/o · encoding · pathlib33How do you write maintainable tests with pytest?Mediumpytest · fixtures · testing34How do you mock dependencies without making tests brittle?Mediummocking · unittest.mock · testing35How do you optimise Python code without wasting effort?Hardperformance · optimization · algorithms36Which Python profiling tools do you use and how do you read them?Hardprofiling · cprofile · benchmarking37How do you structure a Python project for production?Mediumproject layout · packaging · architecture38How do you use logging correctly in a Python service?Mediumlogging · observability · production39Which security practices matter most in Python services?Hardsecurity · injection · secrets40What Python engineering practices do you consistently apply?Hardbest practices · code quality · tooling

Reading is step one

Now say it out loud.

Understanding an answer and delivering it under pressure are different skills. Rehearse this topic in a live Python mock interview and get scored feedback on depth, clarity and confidence.