π Interview Prep
Python
Mutability, comprehensions, generators, decorators, classes and the standard library: what Python-heavy teams test.
π Learn it from scratch
Visual, hands-on lessons for every pattern in this topic. Do the lesson, then come back and the questions click.
100 questions, most asked first
Ranked by how often each question comes up in real interviews. #1 is the most common.
All patternsData types & mutabilityPythonic codeDecorators & context managersIterators & generatorsFunctionsConcurrencyStandard libraryErrorsOOP & dunder methods
#1π¬The mutable default argument trapData types & mutabilityMediumFree#2π¬List vs tupleData types & mutabilityEasyFree#3π¬is vs ==Data types & mutabilityEasyFree#4π¬Mutable vs immutable types and referencesData types & mutabilityMediumFree#5β¨οΈList comprehensionsPythonic codeEasyFree#6β¨οΈWrite a decoratorDecorators & context managersMediumFree#7β¨οΈGenerators and yieldIterators & generatorsMediumFree#8π¬*args and **kwargsFunctionsEasyFree#9π¬How do dicts and sets work?Data types & mutabilityMediumFree#10π¬Shallow copy vs deep copyData types & mutabilityMediumFreeπUnlock 90 more Python questions Β· all 1,200 questions for $39/year (about 11Β’ a day)See full access#11π¬What is the GIL?ConcurrencyMediumπ#12β¨οΈCount word frequencyStandard libraryEasyπ#13π¬try / except / else / finallyErrorsEasyπ#14β¨οΈContext managers and withDecorators & context managersMediumπ#15β¨οΈDunder (magic) methodsOOP & dunder methodsMediumπ#16π¬__init__ vs __new__OOP & dunder methodsHardπ#17π¬classmethod vs staticmethodOOP & dunder methodsMediumπ#18π¬Inheritance, super() and the MROOOP & dunder methodsHardπ#19β¨οΈlambda, map, filter and sorted with keyFunctionsEasyπ#20π¬SlicingPythonic codeEasyπ#21β¨οΈenumerate and zipPythonic codeEasyπ#22β¨οΈdict.get, setdefault and defaultdictStandard libraryEasyπ#23π¬dataclasses and namedtuplesOOP & dunder methodsMediumπ#24π¬Scope rules (LEGB), global and nonlocalFunctionsMediumπ#25π¬Late-binding closures in loopsFunctionsHardπ#26β¨οΈBuild an iterator classIterators & generatorsMediumπ#27π¬Threading vs multiprocessing vs asyncioConcurrencyMediumπ#28π¬async and await in PythonConcurrencyMediumπ#29π¬f-strings and string formattingPythonic codeEasyπ#30π¬Integer division and modulo with negativesData types & mutabilityMediumπ#31π¬Truthiness in PythonData types & mutabilityEasyπ#32π¬Checking for NoneData types & mutabilityEasyπ#33π¬The walrus operator (:=)Pythonic codeEasyπ#34π¬Unpacking and star expressionsPythonic codeEasyπ#35β¨οΈInvert a dictionary (dict comprehension)Pythonic codeEasyπ#36β¨οΈSet operationsData types & mutabilityEasyπ#37β¨οΈFlatten a nested list (recursion + generators)Iterators & generatorsMediumπ#38β¨οΈMemoization with functools.lru_cacheDecorators & context managersEasyπ#39β¨οΈ@property: getters and settersOOP & dunder methodsMediumπ#40π¬__slots__OOP & dunder methodsHardπ#41π¬Abstract base classesOOP & dunder methodsMediumπ#42π¬Duck typing and EAFPOOP & dunder methodsEasyπ#43π¬Type hints in PythonFunctionsEasyπ#44π¬Virtual environments and dependenciesStandard libraryEasyπ#45π¬if __name__ == "__main__"Standard libraryEasyπ#46β¨οΈWorking with JSONStandard libraryEasyπ#47π¬Dates and time zonesStandard libraryMediumπ#48β¨οΈRegular expressions with reStandard libraryMediumπ#49β¨οΈitertools in practiceStandard libraryMediumπ#50β¨οΈheapq for top-k and schedulingStandard libraryMediumπ#51β¨οΈBinary search with bisectStandard libraryMediumπ#52β¨οΈdeque for queues and sliding windowsStandard libraryMediumπ#53π¬Why use join to build strings?Pythonic codeMediumπ#54π¬append vs extend vs +Data types & mutabilityEasyπ#55π¬list.sort() vs sorted()Pythonic codeEasyπ#56π¬Chained comparisonsPythonic codeEasyπ#57β¨οΈany() and all()Pythonic codeEasyπ#58β¨οΈCustom exceptionsErrorsMediumπ#59π¬Exception chaining with raise fromErrorsMediumπ#60π¬logging vs printStandard libraryEasyπ#61π¬Testing with pytestFunctionsEasyπ#62π¬Memory management in PythonData types & mutabilityMediumπ#63π¬Why does `is` work for small numbers?Data types & mutabilityMediumπ#64π¬What does range() actually return?Iterators & generatorsEasyπ#65π¬Generator expressions vs list comprehensionsIterators & generatorsMediumπ#66π¬DescriptorsOOP & dunder methodsHardπ#67π¬MetaclassesOOP & dunder methodsHardπ#68π¬__eq__ and __hash__ togetherOOP & dunder methodsHardπ#69β¨οΈMaking objects sortableOOP & dunder methodsMediumπ#70π¬__str__ vs __repr__OOP & dunder methodsEasyπ#71β¨οΈfunctools.partialFunctionsEasyπ#72β¨οΈfunctools.reduceFunctionsEasyπ#73π¬map/filter vs comprehensionsPythonic codeEasyπ#74β¨οΈzip vs zip_longestStandard libraryEasyπ#75π¬The forβ¦else clausePythonic codeMediumπ#76π¬return inside finallyErrorsHardπ#77π¬Python integers never overflowData types & mutabilityEasyπ#78π¬Floats vs Decimal for moneyStandard libraryMediumπ#79π¬str vs bytes and encodingsData types & mutabilityMediumπ#80β¨οΈSorting by multiple keysPythonic codeMediumπ#81π¬Class attributes vs instance attributesOOP & dunder methodsMediumπ#82π¬Private attributes and name manglingOOP & dunder methodsMediumπ#83β¨οΈEnumsStandard libraryEasyπ#84π¬Race conditions and locks in PythonConcurrencyMediumπ#85π¬Flask vs Django vs FastAPIStandard libraryEasyπ#86π¬WSGI vs ASGIConcurrencyMediumπ#87π¬PEP 8 and clean PythonPythonic codeEasyπ#88π¬Finding slow Python codeStandard libraryMediumπ#89π¬Why is NumPy fast?Standard libraryMediumπ#90π¬Time complexity of Python built-insData types & mutabilityMediumπ#91π¬break, continue and passPythonic codeEasyπ#92β¨οΈString cleanup β make a URL slugPythonic codeEasyπ#93π¬Are dictionaries ordered?Data types & mutabilityEasyπ#94β¨οΈTranspose a matrix with zipPythonic codeEasyπ#95β¨οΈA decorator that takes argumentsDecorators & context managersHardπ#96π¬When to use assertErrorsMediumπ#97β¨οΈReading a file line by lineDecorators & context managersEasyπ#98π¬Is Python compiled or interpreted?FunctionsMediumπ#99π¬Structural pattern matching (match/case)Pythonic codeMediumπ#100β¨οΈClosures in PythonFunctionsEasyπ