In this we are going to see a basic program of multiple inheritance for attributes of parent class in Python Programming Language.
# Parent class created
class Father:
fathername = ""
def show_father(self):
print("Father: ",self.fathername)
class Mother:
mothername = ""
def show_mother(self):
print("Mother: ",self.mothername)
# Child class created inherits Parent class
class Child(Father,Mother):
childname = ""
def show_child(self):
print("Child: ",self.childname)
ch1 = Child()
ch1.fathername = "Mark"
ch1.mothername = "Lily"
ch1.childname = "John"
ch1.show_father()
ch1.show_mother()
ch1.show_child()
# Coded by SAAHIL
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP