Skip to content

Commit 5560ca3

Browse files
authored
Merge pull request #146 from gtdang/part0-nb00-suggestions
Part0 Notebook 00 suggestions
2 parents 3b6122d + 3b5ec65 commit 5560ca3

File tree

2 files changed

+35
-23
lines changed

2 files changed

+35
-23
lines changed

notebooks/part0_python_intro/00_python_basics_review.ipynb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -203,6 +203,13 @@
203203
"keyword.kwlist"
204204
]
205205
},
206+
{
207+
"cell_type": "markdown",
208+
"metadata": {},
209+
"source": [
210+
"There are also built-in objects that should not be used as variable names."
211+
]
212+
},
206213
{
207214
"cell_type": "code",
208215
"execution_count": null,
@@ -1369,7 +1376,7 @@
13691376
],
13701377
"metadata": {
13711378
"kernelspec": {
1372-
"display_name": "pyclass",
1379+
"display_name": "Python 3 (ipykernel)",
13731380
"language": "python",
13741381
"name": "python3"
13751382
},
@@ -1383,7 +1390,7 @@
13831390
"name": "python",
13841391
"nbconvert_exporter": "python",
13851392
"pygments_lexer": "ipython3",
1386-
"version": "3.11.7"
1393+
"version": "3.11.10"
13871394
}
13881395
},
13891396
"nbformat": 4,

notebooks/part0_python_intro/00_skills_test_on_basics.ipynb

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,21 +46,9 @@
4646
"metadata": {},
4747
"outputs": [],
4848
"source": [
49+
"# Read file as a list of lines\n",
4950
"speech_raw = open(datapath / 'dream.txt').readlines() \n",
50-
"speech = [i.strip() for i in speech_raw]"
51-
]
52-
},
53-
{
54-
"cell_type": "code",
55-
"execution_count": null,
56-
"id": "a536464e",
57-
"metadata": {},
58-
"outputs": [],
59-
"source": [
60-
"words = []\n",
61-
"for i in speech:\n",
62-
" words.append(i)\n",
63-
"words"
51+
"speech = [i.strip() for i in speech_raw] # Remove white space around each line"
6452
]
6553
},
6654
{
@@ -70,8 +58,9 @@
7058
"metadata": {},
7159
"outputs": [],
7260
"source": [
73-
"words = ' '.join(words)\n",
74-
"words"
61+
"# join all lines as one big string\n",
62+
"speech_string = ' '.join(speech)\n",
63+
"speech_string"
7564
]
7665
},
7766
{
@@ -82,7 +71,7 @@
8271
"outputs": [],
8372
"source": [
8473
"# put this all in lower case\n",
85-
"words = words.lower()"
74+
"speech_string = speech_string.lower()"
8675
]
8776
},
8877
{
@@ -95,18 +84,20 @@
9584
"# get rid of punctuation using replace and replacing with empty string (e.g. '')\n",
9685
"punks = ['.',',',':',';','!','-']\n",
9786
"for cp in punks:\n",
98-
" words = words.replace(cp, '')"
87+
" speech_string = speech_string.replace(cp, '')"
9988
]
10089
},
10190
{
10291
"cell_type": "code",
10392
"execution_count": null,
10493
"id": "b755a4ce",
105-
"metadata": {},
94+
"metadata": {
95+
"scrolled": true
96+
},
10697
"outputs": [],
10798
"source": [
10899
"# finally split on \"whitespace\" resulting in a list of words\n",
109-
"words = words.split()\n",
100+
"words = speech_string.split()\n",
110101
"words"
111102
]
112103
},
@@ -292,8 +283,22 @@
292283
}
293284
],
294285
"metadata": {
286+
"kernelspec": {
287+
"display_name": "Python 3 (ipykernel)",
288+
"language": "python",
289+
"name": "python3"
290+
},
295291
"language_info": {
296-
"name": "python"
292+
"codemirror_mode": {
293+
"name": "ipython",
294+
"version": 3
295+
},
296+
"file_extension": ".py",
297+
"mimetype": "text/x-python",
298+
"name": "python",
299+
"nbconvert_exporter": "python",
300+
"pygments_lexer": "ipython3",
301+
"version": "3.11.10"
297302
}
298303
},
299304
"nbformat": 4,

0 commit comments

Comments
 (0)