🐍 Python Beginner

What is object-oriented programming in Python?

Why Interviewers Ask This

Foundational questions like this help interviewers calibrate the rest of the interview. A confident, accurate answer signals that you have solid Python basics — a prerequisite for any developer role.

Answer

Python supports full OOP through classes. Define a class: class Animal: def __init__(self, name): self.name = name; def speak(self): raise NotImplementedError. Instantiate: dog = Animal("Rex"). Inheritance: class Dog(Animal): def speak(self): return "Woof!". Call parent: super().__init__(name). Access modifiers: Python uses naming conventions — public (regular), _protected (single underscore, convention only), __private (double underscore, name mangling to _ClassName__attr). Class methods: @classmethod def create(cls, name): return cls(name). Static methods: @staticmethod def validate(name): return bool(name). Python supports multiple inheritance: class C(A, B) with MRO (Method Resolution Order) using C3 linearization.

Pro Tip

This topic has Python-specific nuances that differ from general programming. Highlighting those nuances in your answer shows expertise rather than generic knowledge.