Multilevel inheritance

class dad:
basketball = 1

class son(dad):
basketball = 9
dance = 1

def isdance(self):
return f"yea i dance {self.dance} no if times"

class grandson(son):
dance = 6

# def isdance(self):
# return f"jackson can dance very awesomly {self.dance} no of times"


darry = dad()
larry = son()
harry = grandson()

print(harry.isdance())
print(harry.basketball)

Comments

Popular posts from this blog

Steps taken by a compiler to execute a C program

Tokens in C

Variables and Data Types in C