Skip to content

Commit 4ddc6c4

Browse files
committed
Class EX
1 parent c369342 commit 4ddc6c4

File tree

2 files changed

+69
-13
lines changed

2 files changed

+69
-13
lines changed

‎Class.ipynb

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
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+
"Blu is a bird\n",
13+
"Woo is also a bird\n",
14+
"Blu is 10 years old\n",
15+
"Woo is 15 years old\n"
16+
]
17+
}
18+
],
19+
"source": [
20+
"class Parrot:\n",
21+
"\n",
22+
" # class attribute\n",
23+
" species = \"bird\"\n",
24+
"\n",
25+
" # instance attribute\n",
26+
" def __init__(self, name, age):\n",
27+
" self.name = name\n",
28+
" self.age = age\n",
29+
"\n",
30+
"\n",
31+
"blu = Parrot(\"Blu\", 10)\n",
32+
"woo = Parrot(\"Woo\", 15)\n",
33+
"\n",
34+
"print(\"Blu is a {}\".format(blu.species))\n",
35+
"print(\"Woo is also a {}\".format(woo.species))\n",
36+
"\n",
37+
"# access the instance attributes\n",
38+
"print(\"{} is {} years old\".format( blu.name, blu.age))\n",
39+
"print(\"{} is {} years old\".format( woo.name, woo.age))"
40+
]
41+
}
42+
],
43+
"metadata": {
44+
"kernelspec": {
45+
"display_name": "Python 3",
46+
"language": "python",
47+
"name": "python3"
48+
},
49+
"language_info": {
50+
"codemirror_mode": {
51+
"name": "ipython",
52+
"version": 3
53+
},
54+
"file_extension": ".py",
55+
"mimetype": "text/x-python",
56+
"name": "python",
57+
"nbconvert_exporter": "python",
58+
"pygments_lexer": "ipython3",
59+
"version": "3.7.4"
60+
}
61+
},
62+
"nbformat": 4,
63+
"nbformat_minor": 4
64+
}

‎Employee Getter & Sette.ipynb

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"cells": [
33
{
44
"cell_type": "code",
5-
"execution_count": 22,
5+
"execution_count": 25,
66
"metadata": {},
77
"outputs": [
88
{
@@ -12,19 +12,11 @@
1212
"Soumyadip Chowdhury Soumyadip.Chowdhury@python.com 900000\n",
1313
"Soumyadip Chowdhury Soumyadip.Chowdhury@python.com 100000\n",
1414
"Soumya Dip Soumyadip.Chowdhury@python.com 900000\n",
15+
"Soumyadip Chowdhury Soumyadip.Chowdhury@python.com 100000\n",
16+
"Deleting\n",
17+
"None None Soumyadip.Chowdhury@python.com 900000\n",
1518
"Soumyadip Chowdhury Soumyadip.Chowdhury@python.com 100000\n"
1619
]
17-
},
18-
{
19-
"ename": "TypeError",
20-
"evalue": "setterEx() missing 1 required positional argument: 'name'",
21-
"output_type": "error",
22-
"traceback": [
23-
"\u001b[1;31m---------------------------------------------------------------------------\u001b[0m",
24-
"\u001b[1;31mTypeError\u001b[0m Traceback (most recent call last)",
25-
"\u001b[1;32m<ipython-input-22-6b7ef954cb29>\u001b[0m in \u001b[0;36m<module>\u001b[1;34m\u001b[0m\n\u001b[0;32m 34\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0memp_2\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msetterEx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 35\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[1;32m---> 36\u001b[1;33m \u001b[1;32mdel\u001b[0m \u001b[0memp_1\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msetterEx\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0m\u001b[0;32m 37\u001b[0m \u001b[1;33m\u001b[0m\u001b[0m\n\u001b[0;32m 38\u001b[0m \u001b[0mprint\u001b[0m\u001b[1;33m(\u001b[0m\u001b[0memp_1\u001b[0m\u001b[1;33m.\u001b[0m\u001b[0msetterEx\u001b[0m\u001b[1;33m)\u001b[0m\u001b[1;33m\u001b[0m\u001b[1;33m\u001b[0m\u001b[0m\n",
26-
"\u001b[1;31mTypeError\u001b[0m: setterEx() missing 1 required positional argument: 'name'"
27-
]
2820
}
2921
],
3022
"source": [
@@ -47,7 +39,7 @@
4739
" self.last=last\n",
4840
" \n",
4941
" @setterEx.deleter \n",
50-
" def setterEx(self, name):\n",
42+
" def setterEx(self):\n",
5143
" print(\"Deleting\")\n",
5244
" self.first=None\n",
5345
" self.last=None\n",

0 commit comments

Comments
 (0)