Multiple Inheritance in Python

Multiple inheritance in Python programming is a feature of OOP. In which an object or class can inherit characteristics and features from more than one parent object or parent class.

Program Multiple Inheritance

Program

class cls: #'cls' is name of Class.
    def fun(self):
        print("This is Function of Class cls")
class cls2: #'cls2' is name of Another Class.
    def fun2(self):
        print("This is Function of Class cls2")
class cls3(cls,cls2): #Class 'cls3' is Child of Class 'cls' and 'cls2'.
    def fun3(self):
        print("This is Function of Class cls3")
obj = cls3() #'obj' is object of class 'cls3'.
obj.fun2()
obj.fun3()
obj.fun()
Output
This is Function of Class cls2
This is Function of Class cls3
This is Function of Class cls

Program Inheriting One Class from Multiple Classes

Program

class cls: #'cls' is name of class.
    def fun(self):
        print("This is Function of class cls")
class cls2: #'cls2' is name of another class.
    def fun2(self):
        print("This is Function of class cls2")
class cls3: #'cls3' is name of another class.
    def fun3(self):
        print("This is Function of class cls3")
class cls4(cls2, cls3, cls): #class 'cls4' is Child class of class 'cls2',
    def fun4(self):           #'cls3' and 'cls'.
        print("This is Function of class cls4")
class cls5(cls4): #class 'cls4' is Child class of class 'cls4'.
    def fun5(self):
        print("This is Function of class cls5")
obj = cls5() #'obj' is object of class 'cls5'.
obj.fun()
obj.fun4()
obj.fun2()
obj.fun5()
obj.fun3()
Output
This is Function of class cls
This is Function of class cls4
This is Function of class cls2
This is Function of class cls5
This is Function of class cls3

Multiple Inheritance Calling Functions from Class Function

Program

class cls:
    def fun(self):
        print("Iam Function of class cls")
class cls2:
    def fun2(self):
        print("Iam Function of class cls2")
class cls3:
    def fun3(self):
        print("Iam Function of class cls3")
class cls4(cls2, cls3, cls): #class 'cls4' is Child of class 'cls2',
    def fun4(self):          #'cls3' and 'cls'.
        print("Iam Function of class cls4")
        obj.fun2()
        obj.fun()
        obj.fun3()
class cls5(cls4): #class 'cls5' is Child of class 'cls4'.
    def fun5(self):
        print("Iam Function of class cls5")
        obj.fun4()
obj = cls5() #'obj' is object of class 'cls5'.
obj.fun5()
Output
Iam Function of class cls5
Iam Function of class cls4
Iam Function of class cls2
Iam Function of class cls
Iam Function of class cls3