1# creating parent class
2class Parent:
3 BloodGroup = 'A'
4 Gender = 'Male'
5 Hobby = 'Chess'
6
7# creating child class
8class Child(Parent): # inheriting parent class
9 BloodGroup = 'A+'
10 Gender = 'Female
11
12 def print_data():
13 print(BloodGroup, Gender, Hobby)
14
15# creating object for child class
16child1 = Child()
17# as child1 inherits it's parent's hobby printed data would be it's parent's
18child1.print_data()
19
1class Parent:
2
3 def abc(self):
4 print("Parent")
5
6class LeftChild(Parent):
7
8 def pqr(self):
9 print("Left Child")
10
11class RightChild(Parent):
12
13 def stu(self):
14 print("Right Child")
15
16class GrandChild(LeftChild,RightChild):
17
18 def xyz(self):
19 print("Grand Child")
20
21obj1 = LeftChild()
22obj2 = RightChild()
23obj3 = GrandChild()
24obj1.abc()
25obj2.abc()
26obj3.abc()