← All topics

🐍 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.

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