1class Robot:
2
3 def __init__(self, name):
4 self.name = name
5
6 def say_hi(self):
7 print("Hi, I am " + self.name)
8
9class PhysicianRobot(Robot):
10
11 def say_hi(self):
12 print("Everything will be okay! ")
13 print(self.name + " takes care of you!")
14
15y = PhysicianRobot("James")
16y.say_hi()
17
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()
1class Robot:
2
3 def __init__(self, name):
4 self.name = name
5
6 def say_hi(self):
7 print("Hi, I am " + self.name)
8
9class PhysicianRobot(Robot):
10 pass
11
12x = Robot("Marvin")
13y = PhysicianRobot("James")
14
15print(x, type(x))
16print(y, type(y))
17
18y.say_hi()
19
1<__main__.Robot object at 0x7fd0080b3ba8> <class '__main__.Robot'>
2<__main__.PhysicianRobot object at 0x7fd0080b3b70> <class '__main__.PhysicianRobot'>
3Hi, I am James
4