Interview preparation
Python interview questions
25 lessons in this track
All questions and short answers on one page →
Foundation — the basics
- 1Classes and OOPSelf is an argument, and a class attribute is shared by all30 MIN
- 2Built-in collectionsList, tuple, dict and set — what to use whenClearer after: Classes and OOP30 MIN
- 3Modules and importsA module runs once, and from copies a referenceClearer after: Built-in collections35 MIN
- 4Complexity of operationsO-notation, counted on built-in typesClearer after: Built-in collections25 MIN
- 5Strings and formattingImmutability, slices, f-strings and the cost of concatenationClearer after: Complexity of operations35 MIN
- 6TestingUnittest, pytest and mock — what is really being checkedClearer after: Classes and OOP · Modules and imports40 MIN
- 7Threads and processesWhat to choose for computation, and what for waitingClearer after: Modules and imports25 MIN
- 8Environments & dependenciesEnvironments and dependencies: what venv does, and what pip doesClearer after: Modules and imports25 MIN
Then — by frequency in question listings
- 9DecoratorsExpressions top-down, application bottom-upCome back after: Closures · *args and **kwargs45 MIN
- 10DescriptorsOne precedence rule that property, methods and slots all grow out ofClearer after: Decorators35 MIN
- 11Iterators and generatorsOne method apart, and one silent bug40 MIN
- 12Context managersTwo methods, one returned truth, and one silent data lossCome back after: Exceptions and finally40 MIN
- 13Exceptions and finallyThe one word that stops a function from failing30 MIN
- 14lambdaThe same thing as def except for two — and the famous loop bug is neither of them20 MIN
- 15async/awaitThe call runs nothing — and three bugs that never crash follow from thatClearer after: Iterators and generators · Exceptions and finally · Context managers40 MIN
- 16*args and **kwargsTwo stars with different prices — and one of them makes unknown names acceptable25 MIN
- 17List vs tupleThe 16 bytes you only get from one comparison out of three, and the two operations where there is no differenceCome back after: is versus ==40 MIN
- 18ComprehensionsThe scope boundary runs inside the square brackets, not around themClearer after: Iterators and generatorsCome back after: Closures35 MIN
- 19Closures capture the variable, not the value — and the scope chain walks past the class bodyClearer after: lambda35 MIN
- 20MRO and multiple inheritance: C3, the diamond, and where super() really goesClearer after: Closures25 MIN
- 21CopyingAssignment copies nothing, copy copies one level, deepcopy copies the whole graphClearer after: List vs tupleCome back after: is versus ==25 MIN
- 22is versus ==One asks about identity, the other calls a method — and half the famous surprises are about neither25 MIN
- 23Garbage collectionWhy an object is alive when nothing refers to itClearer after: Exceptions and finally25 MIN
- 24MetaclassesThe six steps of class creation, which show what a metaclass is for and what no longer needs oneClearer after: Descriptors · Decorators25 MIN
- 25Default argumentsMutable default arguments: the value lives in a field of the function, and every call shares it25 MIN
Final check: the Python track
Twenty-five questions across the whole track — one per lesson. Not a recap, but the places where the mechanism gives an answer nobody expects.
Final check1 / 25
The Point class defines __eq__ (equal if the coordinates are equal) but not __hash__. What does {Point(1, 2), Point(1, 2)} give?