Skip to content

Commit f3fadad

Browse files
committed
Merge pull request #95 from johnrudolph08/master
added updates for session 7
2 parents 7ce64ae + 51a0912 commit f3fadad

18 files changed

+2324
-0
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"cells": [],
3+
"metadata": {},
4+
"nbformat": 4,
5+
"nbformat_minor": 0
6+
}
Lines changed: 291 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,291 @@
1+
{
2+
"cells": [
3+
{
4+
"cell_type": "markdown",
5+
"metadata": {},
6+
"source": [
7+
"# Notes on Classes"
8+
]
9+
},
10+
{
11+
"cell_type": "code",
12+
"execution_count": 37,
13+
"metadata": {
14+
"collapsed": false
15+
},
16+
"outputs": [],
17+
"source": [
18+
"class Point(object):\n",
19+
" size = 4\n",
20+
" color = 'red'\n",
21+
" \n",
22+
" \n",
23+
" def __init__(self, x, y):\n",
24+
" origin = 0\n",
25+
" self.x = x\n",
26+
" self.y = y\n",
27+
" self.z = x * y -2\n",
28+
" \n",
29+
" def get_color(self):\n",
30+
" return self.color\n",
31+
" \n",
32+
" \n",
33+
" def get_size(self):\n",
34+
" return self.size\n",
35+
" \n",
36+
" def gimme_two_values(self, a,b):\n",
37+
" self.x = a\n",
38+
" self.y = b"
39+
]
40+
},
41+
{
42+
"cell_type": "code",
43+
"execution_count": 38,
44+
"metadata": {
45+
"collapsed": false
46+
},
47+
"outputs": [],
48+
"source": [
49+
"my_point = Point(2, 3)"
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": 39,
55+
"metadata": {
56+
"collapsed": false
57+
},
58+
"outputs": [
59+
{
60+
"data": {
61+
"text/plain": [
62+
"'red'"
63+
]
64+
},
65+
"execution_count": 39,
66+
"metadata": {},
67+
"output_type": "execute_result"
68+
}
69+
],
70+
"source": [
71+
"my_point.get_color()"
72+
]
73+
},
74+
{
75+
"cell_type": "code",
76+
"execution_count": 40,
77+
"metadata": {
78+
"collapsed": true
79+
},
80+
"outputs": [],
81+
"source": [
82+
"my_other_point = Point(4,5)"
83+
]
84+
},
85+
{
86+
"cell_type": "code",
87+
"execution_count": 41,
88+
"metadata": {
89+
"collapsed": false
90+
},
91+
"outputs": [
92+
{
93+
"data": {
94+
"text/plain": [
95+
"'red'"
96+
]
97+
},
98+
"execution_count": 41,
99+
"metadata": {},
100+
"output_type": "execute_result"
101+
}
102+
],
103+
"source": [
104+
"my_other_point.get_color()"
105+
]
106+
},
107+
{
108+
"cell_type": "code",
109+
"execution_count": 42,
110+
"metadata": {
111+
"collapsed": false
112+
},
113+
"outputs": [
114+
{
115+
"data": {
116+
"text/plain": [
117+
"4"
118+
]
119+
},
120+
"execution_count": 42,
121+
"metadata": {},
122+
"output_type": "execute_result"
123+
}
124+
],
125+
"source": [
126+
"my_other_point.get_size()"
127+
]
128+
},
129+
{
130+
"cell_type": "code",
131+
"execution_count": 43,
132+
"metadata": {
133+
"collapsed": false
134+
},
135+
"outputs": [
136+
{
137+
"data": {
138+
"text/plain": [
139+
"4"
140+
]
141+
},
142+
"execution_count": 43,
143+
"metadata": {},
144+
"output_type": "execute_result"
145+
}
146+
],
147+
"source": [
148+
"my_point.z"
149+
]
150+
},
151+
{
152+
"cell_type": "code",
153+
"execution_count": 44,
154+
"metadata": {
155+
"collapsed": false
156+
},
157+
"outputs": [
158+
{
159+
"data": {
160+
"text/plain": [
161+
"['__class__',\n",
162+
" '__delattr__',\n",
163+
" '__dict__',\n",
164+
" '__dir__',\n",
165+
" '__doc__',\n",
166+
" '__eq__',\n",
167+
" '__format__',\n",
168+
" '__ge__',\n",
169+
" '__getattribute__',\n",
170+
" '__gt__',\n",
171+
" '__hash__',\n",
172+
" '__init__',\n",
173+
" '__le__',\n",
174+
" '__lt__',\n",
175+
" '__module__',\n",
176+
" '__ne__',\n",
177+
" '__new__',\n",
178+
" '__reduce__',\n",
179+
" '__reduce_ex__',\n",
180+
" '__repr__',\n",
181+
" '__setattr__',\n",
182+
" '__sizeof__',\n",
183+
" '__str__',\n",
184+
" '__subclasshook__',\n",
185+
" '__weakref__',\n",
186+
" 'color',\n",
187+
" 'get_color',\n",
188+
" 'get_size',\n",
189+
" 'gimme_two_values',\n",
190+
" 'size',\n",
191+
" 'x',\n",
192+
" 'y',\n",
193+
" 'z']"
194+
]
195+
},
196+
"execution_count": 44,
197+
"metadata": {},
198+
"output_type": "execute_result"
199+
}
200+
],
201+
"source": [
202+
"dir(my_point)"
203+
]
204+
},
205+
{
206+
"cell_type": "code",
207+
"execution_count": 45,
208+
"metadata": {
209+
"collapsed": false
210+
},
211+
"outputs": [],
212+
"source": [
213+
"my_point.gimme_two_values(54, 666)"
214+
]
215+
},
216+
{
217+
"cell_type": "code",
218+
"execution_count": 46,
219+
"metadata": {
220+
"collapsed": false
221+
},
222+
"outputs": [
223+
{
224+
"data": {
225+
"text/plain": [
226+
"54"
227+
]
228+
},
229+
"execution_count": 46,
230+
"metadata": {},
231+
"output_type": "execute_result"
232+
}
233+
],
234+
"source": [
235+
"my_point.x"
236+
]
237+
},
238+
{
239+
"cell_type": "code",
240+
"execution_count": 47,
241+
"metadata": {
242+
"collapsed": false
243+
},
244+
"outputs": [
245+
{
246+
"data": {
247+
"text/plain": [
248+
"'red'"
249+
]
250+
},
251+
"execution_count": 47,
252+
"metadata": {},
253+
"output_type": "execute_result"
254+
}
255+
],
256+
"source": [
257+
"my_point.color"
258+
]
259+
},
260+
{
261+
"cell_type": "code",
262+
"execution_count": null,
263+
"metadata": {
264+
"collapsed": true
265+
},
266+
"outputs": [],
267+
"source": []
268+
}
269+
],
270+
"metadata": {
271+
"kernelspec": {
272+
"display_name": "Python 3",
273+
"language": "python",
274+
"name": "python3"
275+
},
276+
"language_info": {
277+
"codemirror_mode": {
278+
"name": "ipython",
279+
"version": 3
280+
},
281+
"file_extension": ".py",
282+
"mimetype": "text/x-python",
283+
"name": "python",
284+
"nbconvert_exporter": "python",
285+
"pygments_lexer": "ipython3",
286+
"version": "3.4.3"
287+
}
288+
},
289+
"nbformat": 4,
290+
"nbformat_minor": 0
291+
}

0 commit comments

Comments
 (0)