Skip to content

Commit cbde331

Browse files
committed
Assesment
1 parent d836f05 commit cbde331

5 files changed

Lines changed: 255 additions & 160 deletions

File tree

Complete-Python-3-Bootcamp-master/00-Python Object and Data Structure Basics/.ipynb_checkpoints/09-Objects and Data Structures Assessment Test-checkpoint.ipynb

Lines changed: 92 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,15 @@
3838
"source": [
3939
"Double Click HERE to edit this markdown cell and write answers.\n",
4040
"\n",
41-
"Numbers:\n",
41+
"Numbers: Integers (1) / Floating Point (1.1)\n",
4242
"\n",
43-
"Strings:\n",
43+
"Strings: Ordered Sequence of Characters\n",
4444
"\n",
45-
"Lists:\n",
45+
"Lists: Mutable Ordered Sequence of Objects\n",
4646
"\n",
47-
"Tuples:\n",
47+
"Tuples: Immutable Ordered Sequence of Objects\n",
4848
"\n",
49-
"Dictionaries:\n"
49+
"Dictionaries: Unordered Key-Value Pairs \n"
5050
]
5151
},
5252
{
@@ -67,7 +67,9 @@
6767
"collapsed": true
6868
},
6969
"outputs": [],
70-
"source": []
70+
"source": [
71+
"(60+(10**2)/4*7)-134.75"
72+
]
7173
},
7274
{
7375
"cell_type": "markdown",
@@ -76,10 +78,11 @@
7678
"Answer these 3 questions without typing code. Then type code to check your answer.\n",
7779
"\n",
7880
" What is the value of the expression 4 * (6 + 5)\n",
79-
" \n",
81+
" 44\n",
8082
" What is the value of the expression 4 * 6 + 5 \n",
81-
" \n",
82-
" What is the value of the expression 4 + 6 * 5 "
83+
" 29\n",
84+
" What is the value of the expression 4 + 6 * 5\n",
85+
" 34 "
8386
]
8487
},
8588
{
@@ -95,7 +98,8 @@
9598
"cell_type": "markdown",
9699
"metadata": {},
97100
"source": [
98-
"What is the *type* of the result of the expression 3 + 1.5 + 4?<br><br>"
101+
"What is the *type* of the result of the expression 3 + 1.5 + 4?<br><br>\n",
102+
"Float or Floating Point"
99103
]
100104
},
101105
{
@@ -113,7 +117,7 @@
113117
},
114118
"outputs": [],
115119
"source": [
116-
"# Square root:\n"
120+
"# Square root: 100 ** 0.5\n"
117121
]
118122
},
119123
{
@@ -124,7 +128,7 @@
124128
},
125129
"outputs": [],
126130
"source": [
127-
"# Square:\n"
131+
"# Square: 10 ** 2\n"
128132
]
129133
},
130134
{
@@ -151,7 +155,8 @@
151155
"source": [
152156
"s = 'hello'\n",
153157
"# Print out 'e' using indexing\n",
154-
"\n"
158+
"\n",
159+
"s[1]"
155160
]
156161
},
157162
{
@@ -171,7 +176,8 @@
171176
"source": [
172177
"s ='hello'\n",
173178
"# Reverse the string using slicing\n",
174-
"\n"
179+
"\n",
180+
"s[::-1]"
175181
]
176182
},
177183
{
@@ -193,7 +199,8 @@
193199
"# Print out the 'o'\n",
194200
"\n",
195201
"# Method 1:\n",
196-
"\n"
202+
"\n",
203+
"s[4]"
197204
]
198205
},
199206
{
@@ -205,7 +212,8 @@
205212
"outputs": [],
206213
"source": [
207214
"# Method 2:\n",
208-
"\n"
215+
"\n",
216+
"s[-1]"
209217
]
210218
},
211219
{
@@ -230,7 +238,9 @@
230238
},
231239
"outputs": [],
232240
"source": [
233-
"# Method 1:\n"
241+
"# Method 1:\n",
242+
"list=[0,0,0]\n",
243+
"list"
234244
]
235245
},
236246
{
@@ -241,7 +251,8 @@
241251
},
242252
"outputs": [],
243253
"source": [
244-
"# Method 2:\n"
254+
"# Method 2:\n",
255+
"[0]*3"
245256
]
246257
},
247258
{
@@ -260,7 +271,8 @@
260271
"outputs": [],
261272
"source": [
262273
"list3 = [1,2,[3,4,'hello']]\n",
263-
"\n"
274+
"\n",
275+
"list3[2][2] = 'goodbye'"
264276
]
265277
},
266278
{
@@ -278,8 +290,23 @@
278290
},
279291
"outputs": [],
280292
"source": [
293+
"#Method1\n",
294+
"\n",
281295
"list4 = [5,3,4,6,1]\n",
282-
"\n"
296+
"\n",
297+
"sorted(list4)"
298+
]
299+
},
300+
{
301+
"cell_type": "code",
302+
"execution_count": null,
303+
"metadata": {},
304+
"outputs": [],
305+
"source": [
306+
"#Method2\n",
307+
"\n",
308+
"list4.sort()\n",
309+
"list4"
283310
]
284311
},
285312
{
@@ -305,7 +332,9 @@
305332
"outputs": [],
306333
"source": [
307334
"d = {'simple_key':'hello'}\n",
308-
"# Grab 'hello'\n"
335+
"# Grab 'hello'\n",
336+
"\n",
337+
"d['simple_key']"
309338
]
310339
},
311340
{
@@ -317,7 +346,9 @@
317346
"outputs": [],
318347
"source": [
319348
"d = {'k1':{'k2':'hello'}}\n",
320-
"# Grab 'hello'\n"
349+
"# Grab 'hello'\n",
350+
"\n",
351+
"d['k1']['k2']"
321352
]
322353
},
323354
{
@@ -331,7 +362,9 @@
331362
"# Getting a little tricker\n",
332363
"d = {'k1':[{'nest_key':['this is deep',['hello']]}]}\n",
333364
"\n",
334-
"#Grab hello\n"
365+
"#Grab hello\n",
366+
"\n",
367+
"d['k1'][0]['nest_key'][1][0]"
335368
]
336369
},
337370
{
@@ -343,14 +376,18 @@
343376
"outputs": [],
344377
"source": [
345378
"# This will be hard and annoying!\n",
346-
"d = {'k1':[1,2,{'k2':['this is tricky',{'tough':[1,2,['hello']]}]}]}"
379+
"d = {'k1':[1,2,{'k2':['this is tricky',{'tough':[1,2,['hello']]}]}]}\n",
380+
"\n",
381+
"d['k1'][2]['k2'][1]['tough'][2][0]"
347382
]
348383
},
349384
{
350385
"cell_type": "markdown",
351386
"metadata": {},
352387
"source": [
353-
"Can you sort a dictionary? Why or why not?<br><br>"
388+
"Can you sort a dictionary? Why or why not?<br><br>\n",
389+
"\n",
390+
"No (mappings, not a sequence)"
354391
]
355392
},
356393
{
@@ -364,14 +401,19 @@
364401
"cell_type": "markdown",
365402
"metadata": {},
366403
"source": [
367-
"What is the major difference between tuples and lists?<br><br>"
404+
"What is the major difference between tuples and lists?<br><br>\n",
405+
"\n",
406+
"Tuples are immutable"
368407
]
369408
},
370409
{
371410
"cell_type": "markdown",
372411
"metadata": {},
373412
"source": [
374-
"How do you create a tuple?<br><br>"
413+
"How do you create a tuple?<br><br>\n",
414+
"\n",
415+
"Variable = (1,2,3)\n",
416+
" - Parenthesis"
375417
]
376418
},
377419
{
@@ -385,7 +427,9 @@
385427
"cell_type": "markdown",
386428
"metadata": {},
387429
"source": [
388-
"What is unique about a set?<br><br>"
430+
"What is unique about a set?<br><br>\n",
431+
"\n",
432+
"No Duplicates"
389433
]
390434
},
391435
{
@@ -405,7 +449,7 @@
405449
"source": [
406450
"list5 = [1,2,2,33,4,4,11,22,3,3,2]\n",
407451
"\n",
408-
"\n"
452+
"set(list5)\n"
409453
]
410454
},
411455
{
@@ -474,7 +518,9 @@
474518
"outputs": [],
475519
"source": [
476520
"# Answer before running cell\n",
477-
"2 > 3"
521+
"2 > 3\n",
522+
"\n",
523+
"False"
478524
]
479525
},
480526
{
@@ -486,7 +532,9 @@
486532
"outputs": [],
487533
"source": [
488534
"# Answer before running cell\n",
489-
"3 <= 2"
535+
"3 <= 2\n",
536+
"\n",
537+
"False"
490538
]
491539
},
492540
{
@@ -498,7 +546,9 @@
498546
"outputs": [],
499547
"source": [
500548
"# Answer before running cell\n",
501-
"3 == 2.0"
549+
"3 == 2.0\n",
550+
"\n",
551+
"False"
502552
]
503553
},
504554
{
@@ -510,7 +560,9 @@
510560
"outputs": [],
511561
"source": [
512562
"# Answer before running cell\n",
513-
"3.0 == 3"
563+
"3.0 == 3\n",
564+
"\n",
565+
"True"
514566
]
515567
},
516568
{
@@ -522,7 +574,9 @@
522574
"outputs": [],
523575
"source": [
524576
"# Answer before running cell\n",
525-
"4**0.5 != 2"
577+
"4**0.5 != 2\n",
578+
"\n",
579+
"False"
526580
]
527581
},
528582
{
@@ -545,7 +599,9 @@
545599
"l_two = [1,2,{'k1':4}]\n",
546600
"\n",
547601
"# True or False?\n",
548-
"l_one[2][0] >= l_two[2]['k1']"
602+
"l_one[2][0] >= l_two[2]['k1']\n",
603+
"\n",
604+
"Is 3 > 4? FALSE"
549605
]
550606
},
551607
{
@@ -564,16 +620,8 @@
564620
"name": "python3"
565621
},
566622
"language_info": {
567-
"codemirror_mode": {
568-
"name": "ipython",
569-
"version": 3
570-
},
571-
"file_extension": ".py",
572-
"mimetype": "text/x-python",
573623
"name": "python",
574-
"nbconvert_exporter": "python",
575-
"pygments_lexer": "ipython3",
576-
"version": "3.6.6"
624+
"version": "3.12.5"
577625
}
578626
},
579627
"nbformat": 4,

0 commit comments

Comments
 (0)