Skip to content

Commit 950228f

Browse files
authored
Merge pull request #4 from samyag1/Spring2019_ErrorFixes
Fixed typos, incorrect challenge answers, and clarified several topics.
2 parents aff36f1 + 73b7b2d commit 950228f

File tree

8 files changed

+225
-330
lines changed

8 files changed

+225
-330
lines changed

Day_2/07_Lists.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@
167167
"source": [
168168
"* This makes lists different from strings. \n",
169169
"* You cannot change the characters in a [string](https://github.com/dlab-berkeley/python-intensive/blob/master/Glossary.md#string) after it has been created.\n",
170-
" * *Immutable*: cannot be changed after creation.\n",
171-
" * In contrast, lists are *mutable*: they can be modified in place."
170+
" * [*Immutable*](https://github.com/dlab-berkeley/python-fundamentals/blob/master/Glossary.md#immutable): cannot be changed after creation.\n",
171+
" * In contrast, lists are [*mutable*](https://github.com/dlab-berkeley/python-fundamentals/blob/master/Glossary.md#mutable): they can be modified in place."
172172
]
173173
},
174174
{
@@ -677,7 +677,7 @@
677677
"name": "python",
678678
"nbconvert_exporter": "python",
679679
"pygments_lexer": "ipython3",
680-
"version": "3.6.1"
680+
"version": "3.7.1"
681681
}
682682
},
683683
"nbformat": 4,

Day_2/08_Loops.ipynb

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@
207207
"source": [
208208
"* Read `total = total + number` as:\n",
209209
" * Add the current value of the [loop variable](https://github.com/dlab-berkeley/python-intensive/blob/master/Glossary.md#loop-variable) `number` to the current value of the accumulator variable `total`.\n",
210-
" * Assign this new value to to `total`, replacing the current value.\n",
210+
" * Assign this new value to `total`, replacing the current value.\n",
211211
" \n",
212212
"Instead of writing `total = total + number`, this can be simplified to `total += number`. This will reassign total to the current value of total plus the current value of number:"
213213
]
@@ -340,7 +340,7 @@
340340
"\n",
341341
"Below is a list of presidents. Create a new list that contains only the last name of each president.\n",
342342
"\n",
343-
"(HINT: Look at string methods!)"
343+
"(HINT: Use a `for` loop Look at string methods!)"
344344
]
345345
},
346346
{
@@ -369,29 +369,13 @@
369369
"outputs": [],
370370
"source": []
371371
},
372-
{
373-
"cell_type": "markdown",
374-
"metadata": {},
375-
"source": [
376-
"Now sort the list alphabetically by last name (HINT: look up `sorted`):"
377-
]
378-
},
379-
{
380-
"cell_type": "code",
381-
"execution_count": null,
382-
"metadata": {
383-
"collapsed": true
384-
},
385-
"outputs": [],
386-
"source": []
387-
},
388372
{
389373
"cell_type": "markdown",
390374
"metadata": {},
391375
"source": [
392376
"## Challenge 4: Range\n",
393377
"\n",
394-
"Using `range` and a for loop, calculate the factorial of 42 (the product of all integers up to and including 42)."
378+
"Using `range` and a `for` loop to calculate the factorial of 42 (which is the product of all integers up to and including 42)."
395379
]
396380
},
397381
{
@@ -445,7 +429,7 @@
445429
"name": "python",
446430
"nbconvert_exporter": "python",
447431
"pygments_lexer": "ipython3",
448-
"version": "3.6.1"
432+
"version": "3.7.1"
449433
}
450434
},
451435
"nbformat": 4,

Day_2/09_Conditionals.ipynb

Lines changed: 51 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,33 @@
2828
"* * * * *"
2929
]
3030
},
31+
{
32+
"cell_type": "markdown",
33+
"metadata": {},
34+
"source": [
35+
"## `bool` data type\n",
36+
"\n",
37+
"A *Boolean* variable is one that can take the values of either `True` or `False`. They are used to indicate the presence or absence of a certain condition. You can test the value of a variable and a *Boolean* value will be returned. In Python, `bool` is the data type for *Boolean* values."
38+
]
39+
},
40+
{
41+
"cell_type": "code",
42+
"execution_count": null,
43+
"metadata": {},
44+
"outputs": [],
45+
"source": [
46+
"type(True)"
47+
]
48+
},
49+
{
50+
"cell_type": "code",
51+
"execution_count": null,
52+
"metadata": {},
53+
"outputs": [],
54+
"source": [
55+
"5 > 6"
56+
]
57+
},
3158
{
3259
"cell_type": "markdown",
3360
"metadata": {},
@@ -37,7 +64,7 @@
3764
"* An `if` statement (more properly called a *conditional* statement)\n",
3865
" controls whether some block of code is executed or not.\n",
3966
"* Structure is similar to a `for` statement:\n",
40-
" * First line opens with `if` and ends with a colon\n",
67+
" * First line opens with `if`, contains a *Boolean* variable or expression, and ends with a colon\n",
4168
" * Body containing one or more statements is indented (usually by 4 spaces)\n"
4269
]
4370
},
@@ -278,9 +305,7 @@
278305
{
279306
"cell_type": "code",
280307
"execution_count": null,
281-
"metadata": {
282-
"collapsed": true
283-
},
308+
"metadata": {},
284309
"outputs": [],
285310
"source": [
286311
"presidents_full = [\"George Washington\", \"John Adams\", \"Thomas Jefferson\", \"James Madison\", \"James Monroe\", \\\n",
@@ -297,9 +322,7 @@
297322
{
298323
"cell_type": "code",
299324
"execution_count": null,
300-
"metadata": {
301-
"collapsed": true
302-
},
325+
"metadata": {},
303326
"outputs": [],
304327
"source": []
305328
},
@@ -322,9 +345,7 @@
322345
{
323346
"cell_type": "code",
324347
"execution_count": null,
325-
"metadata": {
326-
"collapsed": true
327-
},
348+
"metadata": {},
328349
"outputs": [],
329350
"source": [
330351
"song = '''Row, row, row your boat\n",
@@ -342,17 +363,19 @@
342363
"cell_type": "markdown",
343364
"metadata": {},
344365
"source": [
345-
"Using string methods, for loops, and conditionals, write some code to `print` only the rhyming words (HINT: we'll be simplistic and assume it rhymes if the last 3 characters are the same)"
366+
"Using string methods, for loops, and conditionals, write some code to `print` only the rhyming words. We'll be simplistic and assume it rhymes if the last 3 characters are the same.\n",
367+
"\n",
368+
"(HINT: first remove punctuation using `punctation` below)"
346369
]
347370
},
348371
{
349372
"cell_type": "code",
350373
"execution_count": null,
351-
"metadata": {
352-
"collapsed": true
353-
},
374+
"metadata": {},
354375
"outputs": [],
355-
"source": []
376+
"source": [
377+
"from string import punctuation"
378+
]
356379
},
357380
{
358381
"cell_type": "markdown",
@@ -365,17 +388,17 @@
365388
"cell_type": "markdown",
366389
"metadata": {},
367390
"source": [
368-
"In poetry, an acrostic is a message created by taking certain letters in a pattern over lines. One 9th century German writer, Otfrid of Weissenburg, was notorius for his early use of acrostics, one instance of which is in the text below: *Salomoni episcopo Otfridus*. His message can be found by taking the first character of every other line. Print Otfrid's message! \n",
391+
"In poetry, an acrostic is a message created by taking certain letters in a pattern over lines. One 9th century German writer, Otfrid of Weissenburg, was notorius for his early use of acrostics, one of which is in the text below: *Salomoni episcopo Otfridus*. His message can be found by taking the first character of every other line. Print Otfrid's message! \n",
392+
"\n",
393+
"(HINT: remember what % does, lookup \"enumerate\")\n",
369394
"\n",
370395
"Source: http://titus.uni-frankfurt.de/texte/etcs/germ/ahd/otfrid/otfri.htm"
371396
]
372397
},
373398
{
374399
"cell_type": "code",
375400
"execution_count": null,
376-
"metadata": {
377-
"collapsed": true
378-
},
401+
"metadata": {},
379402
"outputs": [],
380403
"source": [
381404
"text = '''si sálida gimúati sálomones gúati, \n",
@@ -431,32 +454,25 @@
431454
{
432455
"cell_type": "code",
433456
"execution_count": null,
434-
"metadata": {
435-
"collapsed": true
436-
},
457+
"metadata": {},
437458
"outputs": [],
438-
"source": [
439-
"# HINT: remember what % does, lookup enumerate"
440-
]
459+
"source": []
441460
},
442461
{
443462
"cell_type": "markdown",
444463
"metadata": {},
445464
"source": [
446-
"Otfrid was more skillful than to settle for the first letter of every other line. What happens if you extract the last letter of the last word of each line, for every other line starting on the second line?"
465+
"Otfrid was more skillful than to settle for the first letter of every other line. What happens if you extract the last letter of the last word of each line, for every other line starting on the second line?\n",
466+
"\n",
467+
"(HINT: first remove punctuation and lookup \"enumerate\")"
447468
]
448469
},
449470
{
450471
"cell_type": "code",
451472
"execution_count": null,
452-
"metadata": {
453-
"collapsed": true
454-
},
473+
"metadata": {},
455474
"outputs": [],
456-
"source": [
457-
"# HINT: first remove punctuation, tab is represented by \\t, lookup enumerate\n",
458-
"from string import punctuation"
459-
]
475+
"source": []
460476
},
461477
{
462478
"cell_type": "markdown",
@@ -479,9 +495,7 @@
479495
{
480496
"cell_type": "code",
481497
"execution_count": null,
482-
"metadata": {
483-
"collapsed": true
484-
},
498+
"metadata": {},
485499
"outputs": [],
486500
"source": []
487501
}
@@ -502,7 +516,7 @@
502516
"name": "python",
503517
"nbconvert_exporter": "python",
504518
"pygments_lexer": "ipython3",
505-
"version": "3.6.1"
519+
"version": "3.7.1"
506520
}
507521
},
508522
"nbformat": 4,

0 commit comments

Comments
 (0)