|
11 | 11 | "text": [ |
12 | 12 | "1.04\n", |
13 | 13 | "1.04\n", |
14 | | - "1.04\n", |
15 | | - "1.1\n", |
16 | | - "1.1\n", |
17 | | - "1.1\n" |
| 14 | + "Soumyadip\n", |
| 15 | + "Hello\n" |
18 | 16 | ] |
| 17 | + }, |
| 18 | + { |
| 19 | + "data": { |
| 20 | + "text/plain": [ |
| 21 | + "'Soumyadip Chowdhury s.c@python.com 100000'" |
| 22 | + ] |
| 23 | + }, |
| 24 | + "execution_count": 17, |
| 25 | + "metadata": {}, |
| 26 | + "output_type": "execute_result" |
19 | 27 | } |
20 | 28 | ], |
21 | 29 | "source": [ |
|
24 | 32 | " no_empl=0;\n", |
25 | 33 | " raise_amount=1.04\n", |
26 | 34 | " \n", |
27 | | - " def __init__(self,f ,l ,p ):\n", |
28 | | - " self.first=f\n", |
29 | | - " self.last=l\n", |
30 | | - " self.email=f+\".\"+l+\"@python.com\"\n", |
31 | | - " self.pay=p\n", |
| 35 | + " def __init__(self):\n", |
| 36 | + " self.first=\"Soumyadip\"\n", |
| 37 | + " self.last=\"Chowdhury\"\n", |
| 38 | + " self.email=\"s.c@python.com\"\n", |
| 39 | + " self.pay=100000\n", |
32 | 40 | " Employee.no_empl=Employee.no_empl+1\n", |
33 | 41 | " \n", |
34 | 42 | " \n", |
35 | 43 | " def print(self):\n", |
| 44 | + " print(\"Hello\")\n", |
36 | 45 | " return \"{} {} {} {}\".format(self.first,self.last,self.email,self.pay)\n", |
37 | 46 | " \n", |
38 | | - " def apply_raise(self):\n", |
39 | | - " self.pay=int(self.pay* self.raise_amount)\n", |
40 | | - " ## Can print using class,self and obj name \n", |
41 | | - " \n", |
42 | | - " @classmethod\n", |
43 | | - " def set_raise_amt(cls,amount):\n", |
44 | | - " cls.raise_amount=amount\n", |
45 | 47 | " \n", |
46 | 48 | " \n", |
47 | | - "emp_1=Employee(\"Soumyadip\",\"Chowdhury\",900000)\n", |
48 | | - "emp_2=Employee(\"Soumyadip\",\"Chowdhury\",100000)\n", |
49 | | - "\n", |
| 49 | + "emp_1=Employee()\n", |
50 | 50 | "print(Employee.raise_amount)\n", |
51 | 51 | "print(emp_1.raise_amount)\n", |
52 | | - "print(emp_2.raise_amount)\n", |
53 | 52 | "\n", |
54 | | - "Employee.set_raise_amt(1.10)\n", |
55 | | - "\n", |
56 | | - "print(Employee.raise_amount)\n", |
57 | | - "print(emp_1.raise_amount)\n", |
58 | | - "print(emp_2.raise_amount)" |
| 53 | + "print(emp_1.first)\n", |
| 54 | + "emp_1.print()" |
59 | 55 | ] |
60 | 56 | }, |
61 | 57 | { |
|
0 commit comments