Python Single Inheritance

Deriving one or more sub classes from a single base class is called 'single inheritance'. In single inheritance, we always have only one base class, but there can be n number of sub classes derived from it. For example, 'Bank' is a single base class from where we derive 'AndhraBank' and 'StateBank' as sub classes. This is called single inheritance. Consider Figure.It is convention that we should use the arrow head towards the base class (i.e. super class) in the inheritance diagrams.

single inheritance example

Single Inheritance Example

we are deriving two sub classes AndhraBank and StateBank from the single base class, i.e. Bank. All the members (i.e. variables and methods) of Bank class will be available to the sub classes. In the Bank class, we have 'cash' variable and a method to display that, as:

A Python program showing single inheritance in which two sub classes are derived from a single base class.