Public and Private access specifies in python
# Public = every one have access
# Protected = Only some user have access
# Private = Only you have access
class dad:
basketball = 1
_sigrate = 2
__alcohol = 3
class son(dad):
# basketball = 3
dance = 1
def isdance(self):
return f"Yes I dance {self.dance} no of times"
class Grandson(son):
dance = 5
# def isdance(self):
# return F"Jackson yeah! Yes I dance very awesomely {self.dance} no of times"
darry = dad()
larry = son()
narry = Grandson()
# print(narry._dad__alcohol)# this is how we can access a prinvate variable
# print(narry._sigrate)# protected variable
print(narry.basketball)
Comments
Post a Comment