-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path4_selfPython.py
43 lines (39 loc) · 1.02 KB
/
4_selfPython.py
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
36
37
38
39
40
41
42
43
#C0d3 n0=4
#made By GuND0Wn151
"""
self has the address of the object whihc we are making
when print self we get a output like
__main__.object(or)classname at (adress in hex decimal)
"""
class Computer:
"""
when ever we make a method we have to provide self as a paramter
whihc assings the values to self
"""
def __init__(self):
print("IN Init")
def processor(self,model):
self.name=model
def ramSize(self,ram):
self.ram=ram
def display(self):
print("The processor is",self.name)
print("the ram size is ",self.ram)
"""
method whihc prints the self adress
"""
def whatIsSelf(self):
print(self)
"""
when we are calling a method like
pc1.display()
the pc1 is taken as a object so
in this case self = pc1
and pc1 is a object of class COmputer
so we get output at <__main__.Computer object at randomadress_in_hex>
"""
pc1=Computer()
pc1.processor("I5")
pc1.ramSize(16)
pc1.display()
pc1.whatIsSelf()