In this we are going to see a basic program of family using hierarchical inheritance in Python Programming Language.
class Grandparent:
gparentname = ""
def show_gparent(self):
print("GrandParent:",self.gparentname)
class Father(Grandparent):
fathername = ""
def show_father(self):
print("Father:",self.fathername)
class Mother(Grandparent):
mothername = ""
def show_mother(self):
print("Mother:",self.mothername)
g = Grandparent()
g.gparentname = "Tom"
f = Father()
f.fathername = "Mark"
m = Mother()
m.mothername = "Lily"
g.show_gparent()
f.show_father()
m.show_mother()
# Coded by Saahil
#ENJOY CODING
Post a Comment
FOR ANY DOUBTS AND ERRORS FEEL FREE TO ASK. YOUR DOUBTS WILL BE ADDRESSED ASAP