-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconstructer.py
131 lines (77 loc) · 1.93 KB
/
constructer.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
'''class contructer:
def display(self):
print("Inside method")
def __init__(self):
print("Inside consuster")
c1=contructer()
c1.display()#Inside consuster # Inside method'''
###############################
'''class contructer:
def display(self,a,b):
print(a)
print(b)
self.a=a
self.b=b
def display1(self):
print(self.a*self.b)
c=contructer()
c.display(10,20) #10 #20
c.display1()#200
############################### Using constructor above program############
class contructer:
def __init__(self,a,b):
print(a)
print(b)
self.a=a
self.b=b
def display1(self):
print(self.a*self.b)#10#20
c=contructer(10,20)
c.display1()#200
##################calling one method from another method
class construct:
def display(self):
print("first method")
self.display1(100)
def display1(self,a):
print("second method",a)
c=construct()
c.display1()
################
class Emp:
def __init__(self,id,name,sex):
self.id=id
self.name=name
self.sex=sex
def display(self):
print("Empid:{} Empname:{} Empsex:{}".format(self.id,self.name,self.sex))
c1=Emp()
c1.display(10,'lucky','male')'''
###########__if we want to print the object refernece
class Object:
pass
c=Object()
print(c) #<__main__.Object object at 0x0148AD30>
###########__str__ used to give meaningful representation of object
class Object:
def __str__(self):
return "welcome"
c=Object()
print(c)#welcome
################
class Emp:
def __init__(self,id,name,sex):
self.id=id
self.name=name
self.sex=sex
def __str__(self):
return ("Empid:{} Empname:{} Empsex:{}".format(self.id,self.name,self.sex))
c1=Emp(10,'lucky','male')
print(c1)
########Destory the objects
class object:
def __del__(self):
print("destory")
c1=object()
c2=object()
del c1