- Executors
-
Learn
Learn Python Runnable examples, NumPy, pandas, and more Learn AI / Machine LearningNeural networks, ML and LLMs from scratch Learn C & C++ Pointers, memory, STL, and modern C++ Learn C#C# basics, OOP, LINQ, async, and .NET exercises Learn MatplotlibLine, bar, scatter and pie charts with live visualizers Learn RustOwnership, traits, error handling, and threads Learn GoSlices, interfaces, goroutines, and channels Python Algorithms Search, sorting, recursion, and visualizers O(n) C & C++ Algorithms Compare algorithms implemented in C and C++ Coding for Kids Learn to code by playing!
- QuizzesNew
- ChallengesNew
- For TeachersNew
- Updates
- Buy me a coffee
Python Python OOP Interview Questions Quiz
This Python quiz covers the object-oriented questions that come up in most Python interviews. You will trace super() through multiple inheritance, see what name mangling really does, and check your understanding of abstract classes, __slots__ and duck typing.
Sample question
Question 1 of 10What does this print?
class Basket:
items = []
def add(self, item):
self.items.append(item)
a = Basket()
b = Basket()
a.add("apple")
print(b.items)
Show the answer
B. ['apple'] items is a class attribute, so there is one list shared by every Basket. self.items.append changes that shared list. Create the list in __init__ with self.items = [] to give each object its own.
What this quiz covers
- Shared mutable class attributes
super()and the MRO in multiple inheritance- Name mangling with
__name - Abstract base classes and
__slots__ - Duck typing and composition
Questions people ask
Do I need an account?
No. Anyone can play. Sign in to keep your XP, streak, badges and history.
Which Python version?
Python 3.12. Every question about output was checked by running the code.
Can I retake it?
Yes. Your best score is kept, and the questions and answers are shuffled each time.