Inheritance is a way by which a subclass can inherit the attributes and methods of another class. The new class is called derived (or child) class and the one from which it inherits is called the base (or parent) class.
The general syntax for single class inheritance is:
class BaseClass:
Base class body
class DerivedClass(BaseClass):
Derived class body
The general syntax for multiple class inheritance is:
class BaseClass1:
Base class1 body
class BaseClass:
Base class2 body
class DerivedClass(BaseClass1,BaseClass2):
Derived class body
In multilevel inheritance, the derived class is derived from another derived class.
The general syntax for multilevel class inheritance is:
class Base:
Base Class body
class Derived1(Base):
Derived Class1 body
class Derived2(Derived1):
Derived Class2 body
Free Resources