python how to inherit a class code example

Example 1: Inheritance example python

class Parent:

    def abc(self):
        print("Parent")

class LeftChild(Parent):

    def pqr(self):
        print("Left Child")

class RightChild(Parent):

    def stu(self):
        print("Right Child")

class GrandChild(LeftChild,RightChild):

    def xyz(self):
        print("Grand Child")

obj1 = LeftChild()
obj2 = RightChild()
obj3 = GrandChild()
obj1.abc()
obj2.abc()
obj3.abc()

Example 2: how to inherit a class in python

class Bird():
        def eat(self):
                print ("eating")
 
class Sparrow(Bird):
        def sound(self):
                print ("ChiChi!")
 
birdobj = Sparrow()
birdobj.eat()
birdobj.sound()