Skip to content

Commit 2518677

Browse files
committed
Static methgod
1 parent da4cc8c commit 2518677

File tree

2 files changed

+86
-5
lines changed

2 files changed

+86
-5
lines changed

Employee Class & Static Method.ipynb renamed to Employee Class.ipynb

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 13,
5+
"execution_count": 17,
66
"metadata": {},
77
"outputs": [
88
{
@@ -12,9 +12,9 @@
1212
"1.04\n",
1313
"1.04\n",
1414
"1.04\n",
15-
"1.04\n",
16-
"1.04\n",
17-
"1.0\n"
15+
"1.1\n",
16+
"1.1\n",
17+
"1.1\n"
1818
]
1919
}
2020
],
@@ -43,6 +43,7 @@
4343
" def set_raise_amt(cls,amount):\n",
4444
" cls.raise_amount=amount\n",
4545
" \n",
46+
" \n",
4647
"emp_1=Employee(\"Soumyadip\",\"Chowdhury\",900000)\n",
4748
"emp_2=Employee(\"Soumyadip\",\"Chowdhury\",100000)\n",
4849
"\n",
@@ -51,7 +52,6 @@
5152
"print(emp_2.raise_amount)\n",
5253
"\n",
5354
"Employee.set_raise_amt(1.10)\n",
54-
"emp_2.set_raise_amt(1.0)\n",
5555
"\n",
5656
"print(Employee.raise_amount)\n",
5757
"print(emp_1.raise_amount)\n",

Employee Static Method.ipynb

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "code",
5+
"execution_count": 4,
6+
"metadata": {},
7+
"outputs": [
8+
{
9+
"name": "stdout",
10+
"output_type": "stream",
11+
"text": [
12+
"True\n"
13+
]
14+
}
15+
],
16+
"source": [
17+
"class Employee:\n",
18+
" \n",
19+
" no_empl=0;\n",
20+
" raise_amount=1.04\n",
21+
" \n",
22+
" def __init__(self,f ,l ,p ):\n",
23+
" self.first=f\n",
24+
" self.last=l\n",
25+
" self.email=f+\".\"+l+\"@python.com\"\n",
26+
" self.pay=p\n",
27+
" Employee.no_empl=Employee.no_empl+1\n",
28+
" \n",
29+
" \n",
30+
" def print(self):\n",
31+
" return \"{} {} {} {}\".format(self.first,self.last,self.email,self.pay)\n",
32+
" \n",
33+
" def apply_raise(self):\n",
34+
" self.pay=int(self.pay* self.raise_amount)\n",
35+
" ## Can print using class,self and obj name \n",
36+
" \n",
37+
" @staticmethod\n",
38+
" def is_workng(day):\n",
39+
" if day.weekday() == 5 or day.weekday() == 6:\n",
40+
" return False\n",
41+
" return True\n",
42+
" \n",
43+
"emp_1=Employee(\"Soumyadip\",\"Chowdhury\",900000)\n",
44+
"emp_2=Employee(\"Soumyadip\",\"Chowdhury\",100000)\n",
45+
"\n",
46+
"import datetime\n",
47+
"\n",
48+
"myBday=datetime.date(2020,3,19)\n",
49+
"print(Employee.is_workng(mydate))"
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": null,
55+
"metadata": {},
56+
"outputs": [],
57+
"source": []
58+
}
59+
],
60+
"metadata": {
61+
"kernelspec": {
62+
"display_name": "Python 3",
63+
"language": "python",
64+
"name": "python3"
65+
},
66+
"language_info": {
67+
"codemirror_mode": {
68+
"name": "ipython",
69+
"version": 3
70+
},
71+
"file_extension": ".py",
72+
"mimetype": "text/x-python",
73+
"name": "python",
74+
"nbconvert_exporter": "python",
75+
"pygments_lexer": "ipython3",
76+
"version": "3.7.4"
77+
}
78+
},
79+
"nbformat": 4,
80+
"nbformat_minor": 4
81+
}

0 commit comments

Comments
 (0)