-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinheritance2.py
More file actions
35 lines (25 loc) · 766 Bytes
/
inheritance2.py
File metadata and controls
35 lines (25 loc) · 766 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
class A():
def __init__(self,name, address,id):
self.name = name
self._address = address #protected access in next class
self.__id = id #privatte not access
class B(A):
def __init__(self,name,address,id,subject):
A.__init__(self,name,address,id)
self.sub = subject
def info(self):
print(self.__id)
self.__id = 123
print(self.__id)
def protected(self):
print(self._address)
class C(B):
def __init__(self,name,address,id,subject,day):
B.__init__(self,name,address,id,subject)
self.day = day
def protected(self):
print( "the id is ",self._address)
c = C("Anil", "Koteshwor",19022,"python","monday")
# print(C.info())
c.protected()
c.info()