Skip to content

Commit 61fe5ab

Browse files
committed
Python course
1 parent a08d4b4 commit 61fe5ab

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

PropertyDecorators.py

+14-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,19 @@
22
# @property_decorators help you to take function as varible
33
class Employee:
44
Name="varinder"
5-
Middle="Singh"
6-
Last="Brar"
5+
pocktmoney=5004
6+
saving=5000
77
@property
8-
def name(self):
9-
return self.Name+" "+self.Middle+" "+self.Last
8+
def totalmoney(self):
9+
return self.pocktmoney+self.saving
10+
11+
@totalmoney.setter
12+
def totalmoney(self,value):
13+
self.saving=value-self.pocktmoney
1014
data=Employee()
11-
print(data.name) #here you get value from function write function as proporty
15+
print(data.totalmoney) #here you get value from function write function as proporty
16+
data.totalmoney=9999
17+
print(data.saving)
18+
print(data.totalmoney)
19+
#if you want to set return value according to your need
20+

0 commit comments

Comments
 (0)