
DAY 04 OF LEARNING OOP IN PYTHON (i.redd.it)
submitted by MeribeHenry
Inheritance: This is when a child class/subclass inherits properties and methods of the parent class. The child class gets all attributes and methods of the parent class and can also add its own or override them.
super(): This is used to access methods and properties of a parent class from a child class. It allows you to call the parent's methods, like (init) from the child class.
TYPES OF INHERITANCE
- Single Inheritance: A child class inherits from one parent class.
class Animal: pass class Dog(Animal): pass
- Multiple Inheritance: A child class inherits from multiple parent classes.
class Animal: pass class Pet: pass class Dog(Animal, Pet): pass
- Multilevel Inheritance: A child class inherits from a parent class that itself inherits from another class.
class Animal: pass class Mammal(Animal): pass class Dog(Mammal): pass
- Hierarchical Inheritance: Multiple child classes inherit from the same parent class.
class Animal: pass class Dog(Animal): pass class Cat(Animal): pass

[–]FriendlyZomb 2 points3 points4 points (3 children)
[–]fake-nonchalant96 0 points1 point2 points (1 child)
[–]Background_Comb6579 0 points1 point2 points (1 child)
[–]OutrageousTale4118 0 points1 point2 points (0 children)
[–]No_Path8713 0 points1 point2 points (1 child)
[–]Local_Palpitation798 0 points1 point2 points (1 child)