Class and object, __init__, self, attributes and methods, inheritance (Human → Doctor/Student), super(), overriding and the 4 OOP principles.
AdvancedReading ≈ 40 minPractice ≈ 25 minNot started
In short
Class and object, __init__, self, attributes and methods, inheritance (Human → Doctor/Student), super(), overriding and the 4 OOP principles.
How it works
🔗 Useful in CCNA / Helpdesk: a Device object with hostname and ip is the basis of network libraries like Netmiko.
A class is a blueprint and an object is a "product" built from it. The Human class describes what every person has; dana = Human("Dana", 30) creates one specific person.
__init__ — a special method that runs automatically when an object is created and fills in its attributes.
self — the current object itself. self.name = name stores the name inside this object.
An attribute is object data: dana.age. A method is a function inside a class: dana.greet().
Inheritance: class Doctor(Human) gets everything Human has and adds its own. super().__init__(name, age) calls the parent's __init__ so you don't repeat code. Overriding: a method with the same name in the child class replaces the parent's.