Multiple Child Classes Inheritance in Python
In this type of Inheritance two to more child classes can inherit from a parent class.
# Parent class created class Parent: parentname = "" childname = "" def show_parent(self): print(self.parentname) # Son class inherits Parent class class Son(Parent): def show_child(self): print(self.childname) # Daughter class inherits Parent class class Daughter(Parent): def show_child(self): print(self.childname) s1 = Son() # Object of Son class s1.parentname = "Mark" s1.childname = "John" s1.show_parent() s1.show_child() d1 = Son() # Object of Daughter class d1.childname = "Riya" d1.parentname = "Samule" d1.show_parent() d1.show_child()
2019-01-09T04:25:58+05:30
2019-01-09T04:25:58+05:30
Amit Arora
Amit Arora
Python Programming Tutorial
Python
Practical Solution