Inheritance is one of the key concepts of object orientated programming (OOP). Objects are created using classes, but that’s not all.
A class can inherit the methods and variables from another class. This principle helps us to avoid duplicate code. In turn, a created object has methods and variables from both classes.
Related course: Complete Python Bootcamp: Go from zero to hero in Python 3
We start by defining a class A which has a method A.
Then we create class B and let it inherit from class A.
If you create an object from class B, it has both the methods defined in class A and class B.
Full inheritance code: