|
54 | 54 | "metadata": {},
|
55 | 55 | "outputs": [],
|
56 | 56 | "source": [
|
57 |
| - "a.append(4)" |
| 57 | + "a.append(4)\n", |
| 58 | + "print(a)" |
58 | 59 | ]
|
59 | 60 | },
|
60 | 61 | {
|
|
63 | 64 | "metadata": {},
|
64 | 65 | "outputs": [],
|
65 | 66 | "source": [
|
66 |
| - "a.insert(1, 1.5)" |
| 67 | + "a.insert(1, 1.5)\n", |
| 68 | + "print(a)" |
67 | 69 | ]
|
68 | 70 | },
|
69 | 71 | {
|
|
72 | 74 | "metadata": {},
|
73 | 75 | "outputs": [],
|
74 | 76 | "source": [
|
75 |
| - "a.extend([5, 6, 7])" |
| 77 | + "a.extend([5, 6, 7])\n", |
| 78 | + "print(a)" |
76 | 79 | ]
|
77 | 80 | },
|
78 | 81 | {
|
|
106 | 109 | "print(a)"
|
107 | 110 | ]
|
108 | 111 | },
|
| 112 | + { |
| 113 | + "cell_type": "code", |
| 114 | + "execution_count": null, |
| 115 | + "metadata": {}, |
| 116 | + "outputs": [], |
| 117 | + "source": [ |
| 118 | + "reversed(a)" |
| 119 | + ] |
| 120 | + }, |
109 | 121 | {
|
110 | 122 | "cell_type": "code",
|
111 | 123 | "execution_count": null,
|
|
121 | 133 | "metadata": {},
|
122 | 134 | "outputs": [],
|
123 | 135 | "source": [
|
124 |
| - "b.sort()" |
| 136 | + "b.sort()\n", |
| 137 | + "print(b)" |
125 | 138 | ]
|
126 | 139 | },
|
127 | 140 | {
|
|
166 | 179 | "metadata": {},
|
167 | 180 | "outputs": [],
|
168 | 181 | "source": [
|
169 |
| - "print(animals[-2])\n", |
| 182 | + "print(animals[-2])" |
| 183 | + ] |
| 184 | + }, |
| 185 | + { |
| 186 | + "cell_type": "code", |
| 187 | + "execution_count": null, |
| 188 | + "metadata": {}, |
| 189 | + "outputs": [], |
| 190 | + "source": [ |
170 | 191 | "print(animals[-2:])"
|
171 | 192 | ]
|
172 | 193 | },
|
|
227 | 248 | },
|
228 | 249 | {
|
229 | 250 | "cell_type": "code",
|
230 |
| - "execution_count": 2, |
| 251 | + "execution_count": null, |
231 | 252 | "metadata": {},
|
232 | 253 | "outputs": [],
|
233 | 254 | "source": [
|
|
237 | 258 | },
|
238 | 259 | {
|
239 | 260 | "cell_type": "code",
|
240 |
| - "execution_count": 3, |
241 |
| - "metadata": {}, |
242 |
| - "outputs": [ |
243 |
| - { |
244 |
| - "data": { |
245 |
| - "text/plain": [ |
246 |
| - "['__and__',\n", |
247 |
| - " '__class__',\n", |
248 |
| - " '__class_getitem__',\n", |
249 |
| - " '__contains__',\n", |
250 |
| - " '__delattr__',\n", |
251 |
| - " '__dir__',\n", |
252 |
| - " '__doc__',\n", |
253 |
| - " '__eq__',\n", |
254 |
| - " '__format__',\n", |
255 |
| - " '__ge__',\n", |
256 |
| - " '__getattribute__',\n", |
257 |
| - " '__gt__',\n", |
258 |
| - " '__hash__',\n", |
259 |
| - " '__iand__',\n", |
260 |
| - " '__init__',\n", |
261 |
| - " '__init_subclass__',\n", |
262 |
| - " '__ior__',\n", |
263 |
| - " '__isub__',\n", |
264 |
| - " '__iter__',\n", |
265 |
| - " '__ixor__',\n", |
266 |
| - " '__le__',\n", |
267 |
| - " '__len__',\n", |
268 |
| - " '__lt__',\n", |
269 |
| - " '__ne__',\n", |
270 |
| - " '__new__',\n", |
271 |
| - " '__or__',\n", |
272 |
| - " '__rand__',\n", |
273 |
| - " '__reduce__',\n", |
274 |
| - " '__reduce_ex__',\n", |
275 |
| - " '__repr__',\n", |
276 |
| - " '__ror__',\n", |
277 |
| - " '__rsub__',\n", |
278 |
| - " '__rxor__',\n", |
279 |
| - " '__setattr__',\n", |
280 |
| - " '__sizeof__',\n", |
281 |
| - " '__str__',\n", |
282 |
| - " '__sub__',\n", |
283 |
| - " '__subclasshook__',\n", |
284 |
| - " '__xor__',\n", |
285 |
| - " 'add',\n", |
286 |
| - " 'clear',\n", |
287 |
| - " 'copy',\n", |
288 |
| - " 'difference',\n", |
289 |
| - " 'difference_update',\n", |
290 |
| - " 'discard',\n", |
291 |
| - " 'intersection',\n", |
292 |
| - " 'intersection_update',\n", |
293 |
| - " 'isdisjoint',\n", |
294 |
| - " 'issubset',\n", |
295 |
| - " 'issuperset',\n", |
296 |
| - " 'pop',\n", |
297 |
| - " 'remove',\n", |
298 |
| - " 'symmetric_difference',\n", |
299 |
| - " 'symmetric_difference_update',\n", |
300 |
| - " 'union',\n", |
301 |
| - " 'update']" |
302 |
| - ] |
303 |
| - }, |
304 |
| - "execution_count": 3, |
305 |
| - "metadata": {}, |
306 |
| - "output_type": "execute_result" |
307 |
| - } |
308 |
| - ], |
| 261 | + "execution_count": null, |
| 262 | + "metadata": {}, |
| 263 | + "outputs": [], |
309 | 264 | "source": [
|
310 | 265 | "dir(my_set)"
|
311 | 266 | ]
|
312 | 267 | },
|
313 | 268 | {
|
314 | 269 | "cell_type": "code",
|
315 |
| - "execution_count": 4, |
316 |
| - "metadata": {}, |
317 |
| - "outputs": [ |
318 |
| - { |
319 |
| - "data": { |
320 |
| - "text/plain": [ |
321 |
| - "['update',\n", |
322 |
| - " 'union',\n", |
323 |
| - " 'symmetric_difference_update',\n", |
324 |
| - " 'symmetric_difference',\n", |
325 |
| - " 'remove',\n", |
326 |
| - " 'pop',\n", |
327 |
| - " 'issuperset',\n", |
328 |
| - " 'issubset',\n", |
329 |
| - " 'isdisjoint',\n", |
330 |
| - " 'intersection_update',\n", |
331 |
| - " 'intersection',\n", |
332 |
| - " 'discard',\n", |
333 |
| - " 'difference_update',\n", |
334 |
| - " 'difference',\n", |
335 |
| - " 'copy',\n", |
336 |
| - " 'clear',\n", |
337 |
| - " 'add',\n", |
338 |
| - " '__xor__',\n", |
339 |
| - " '__subclasshook__',\n", |
340 |
| - " '__sub__',\n", |
341 |
| - " '__str__',\n", |
342 |
| - " '__sizeof__',\n", |
343 |
| - " '__setattr__',\n", |
344 |
| - " '__rxor__',\n", |
345 |
| - " '__rsub__',\n", |
346 |
| - " '__ror__',\n", |
347 |
| - " '__repr__',\n", |
348 |
| - " '__reduce_ex__',\n", |
349 |
| - " '__reduce__',\n", |
350 |
| - " '__rand__',\n", |
351 |
| - " '__or__',\n", |
352 |
| - " '__new__',\n", |
353 |
| - " '__ne__',\n", |
354 |
| - " '__lt__',\n", |
355 |
| - " '__len__',\n", |
356 |
| - " '__le__',\n", |
357 |
| - " '__ixor__',\n", |
358 |
| - " '__iter__',\n", |
359 |
| - " '__isub__',\n", |
360 |
| - " '__ior__',\n", |
361 |
| - " '__init_subclass__',\n", |
362 |
| - " '__init__',\n", |
363 |
| - " '__iand__',\n", |
364 |
| - " '__hash__',\n", |
365 |
| - " '__gt__',\n", |
366 |
| - " '__getattribute__',\n", |
367 |
| - " '__ge__',\n", |
368 |
| - " '__format__',\n", |
369 |
| - " '__eq__',\n", |
370 |
| - " '__doc__',\n", |
371 |
| - " '__dir__',\n", |
372 |
| - " '__delattr__',\n", |
373 |
| - " '__contains__',\n", |
374 |
| - " '__class_getitem__',\n", |
375 |
| - " '__class__',\n", |
376 |
| - " '__and__']" |
377 |
| - ] |
378 |
| - }, |
379 |
| - "execution_count": 4, |
380 |
| - "metadata": {}, |
381 |
| - "output_type": "execute_result" |
382 |
| - } |
383 |
| - ], |
| 270 | + "execution_count": null, |
| 271 | + "metadata": {}, |
| 272 | + "outputs": [], |
384 | 273 | "source": [
|
385 | 274 | "list(reversed(dir(my_set)))"
|
386 | 275 | ]
|
|
478 | 367 | "metadata": {},
|
479 | 368 | "outputs": [],
|
480 | 369 | "source": [
|
481 |
| - "print(sample_dict[\"one\"])\n", |
482 |
| - "print(sample_dict.get(\"two\"))\n", |
| 370 | + "print(sample_dict[\"one\"])" |
| 371 | + ] |
| 372 | + }, |
| 373 | + { |
| 374 | + "cell_type": "code", |
| 375 | + "execution_count": null, |
| 376 | + "metadata": {}, |
| 377 | + "outputs": [], |
| 378 | + "source": [ |
| 379 | + "print(sample_dict.get(\"two\"))" |
| 380 | + ] |
| 381 | + }, |
| 382 | + { |
| 383 | + "cell_type": "code", |
| 384 | + "execution_count": null, |
| 385 | + "metadata": {}, |
| 386 | + "outputs": [], |
| 387 | + "source": [ |
483 | 388 | "print(sample_dict.get(\"four\", 4))"
|
484 | 389 | ]
|
485 | 390 | },
|
|
551 | 456 | "cell_type": "markdown",
|
552 | 457 | "metadata": {},
|
553 | 458 | "source": [
|
554 |
| - "1. Create a list of dictionaries\n", |
555 |
| - "2. Show an example of where sets would work better than lists" |
| 459 | + "1. Store the marks of 4 subjects for 3 students. You should be able to retrieve all the marks easily with the student's name.\n", |
| 460 | + "2. Show an example of where sets would work better than lists.\n", |
| 461 | + "3. Store your idsid and password. You should not be able to modify this after setting it the first time." |
556 | 462 | ]
|
557 | 463 | },
|
558 | 464 | {
|
|
0 commit comments