Skip to content

Commit 1c6c714

Browse files
committed
move list comprehensions
1 parent c0a21c7 commit 1c6c714

File tree

2 files changed

+71
-126
lines changed

2 files changed

+71
-126
lines changed

content/01-python/w2-python-advanced-datatypes.ipynb

Lines changed: 0 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -178,29 +178,6 @@
178178
"a"
179179
]
180180
},
181-
{
182-
"cell_type": "code",
183-
"execution_count": 7,
184-
"metadata": {
185-
"tags": []
186-
},
187-
"outputs": [
188-
{
189-
"data": {
190-
"text/plain": [
191-
"[-1, -2.1, -2.0, 'my list', 4]"
192-
]
193-
},
194-
"execution_count": 7,
195-
"metadata": {},
196-
"output_type": "execute_result"
197-
}
198-
],
199-
"source": [
200-
"a[0:1] = [-1, -2.1] # this will put two items in the spot where 1 existed before\n",
201-
"a"
202-
]
203-
},
204181
{
205182
"cell_type": "markdown",
206183
"metadata": {},
@@ -731,69 +708,6 @@
731708
"outputs": [],
732709
"source": []
733710
},
734-
{
735-
"cell_type": "markdown",
736-
"metadata": {},
737-
"source": [
738-
"## List Comprehensions"
739-
]
740-
},
741-
{
742-
"cell_type": "markdown",
743-
"metadata": {},
744-
"source": [
745-
"list comprehensions provide a compact way to initialize lists. Some examples from the tutorial"
746-
]
747-
},
748-
{
749-
"cell_type": "code",
750-
"execution_count": 25,
751-
"metadata": {},
752-
"outputs": [],
753-
"source": [
754-
"squares = [x**2 for x in range(10)]"
755-
]
756-
},
757-
{
758-
"cell_type": "code",
759-
"execution_count": 26,
760-
"metadata": {
761-
"tags": []
762-
},
763-
"outputs": [
764-
{
765-
"data": {
766-
"text/plain": [
767-
"[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]"
768-
]
769-
},
770-
"execution_count": 26,
771-
"metadata": {},
772-
"output_type": "execute_result"
773-
}
774-
],
775-
"source": [
776-
"squares"
777-
]
778-
},
779-
{
780-
"cell_type": "markdown",
781-
"metadata": {},
782-
"source": [
783-
"````{admonition} Quick Exercise\n",
784-
"\n",
785-
"Use a list comprehension to create a new list from `squares` containing only the even numbers. It might be helpful to use the modulus operator, `%`\n",
786-
"\n",
787-
"````"
788-
]
789-
},
790-
{
791-
"cell_type": "code",
792-
"execution_count": null,
793-
"metadata": {},
794-
"outputs": [],
795-
"source": []
796-
},
797711
{
798712
"cell_type": "markdown",
799713
"metadata": {},
@@ -976,45 +890,6 @@
976890
"points.append((3,4))\n",
977891
"points"
978892
]
979-
},
980-
{
981-
"cell_type": "markdown",
982-
"metadata": {},
983-
"source": [
984-
"we can even generate these for a curve using a list comprehension:"
985-
]
986-
},
987-
{
988-
"cell_type": "code",
989-
"execution_count": 35,
990-
"metadata": {
991-
"tags": []
992-
},
993-
"outputs": [
994-
{
995-
"data": {
996-
"text/plain": [
997-
"[(0, 5),\n",
998-
" (1, 7),\n",
999-
" (2, 9),\n",
1000-
" (3, 11),\n",
1001-
" (4, 13),\n",
1002-
" (5, 15),\n",
1003-
" (6, 17),\n",
1004-
" (7, 19),\n",
1005-
" (8, 21),\n",
1006-
" (9, 23)]"
1007-
]
1008-
},
1009-
"execution_count": 35,
1010-
"metadata": {},
1011-
"output_type": "execute_result"
1012-
}
1013-
],
1014-
"source": [
1015-
"points = [(x, 2*x + 5) for x in range(10)]\n",
1016-
"points"
1017-
]
1018893
}
1019894
],
1020895
"metadata": {

content/01-python/w2-python-control-flow.ipynb

Lines changed: 71 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,76 @@
383383
"````"
384384
]
385385
},
386+
{
387+
"cell_type": "code",
388+
"execution_count": null,
389+
"metadata": {},
390+
"outputs": [],
391+
"source": []
392+
},
393+
{
394+
"cell_type": "code",
395+
"execution_count": null,
396+
"metadata": {},
397+
"outputs": [],
398+
"source": []
399+
},
400+
{
401+
"cell_type": "markdown",
402+
"metadata": {},
403+
"source": [
404+
"## List Comprehensions"
405+
]
406+
},
407+
{
408+
"cell_type": "markdown",
409+
"metadata": {},
410+
"source": [
411+
"list comprehensions provide a compact way to initialize lists. Some examples from the tutorial"
412+
]
413+
},
414+
{
415+
"cell_type": "code",
416+
"execution_count": 25,
417+
"metadata": {},
418+
"outputs": [],
419+
"source": [
420+
"squares = [x**2 for x in range(10)]"
421+
]
422+
},
423+
{
424+
"cell_type": "code",
425+
"execution_count": 26,
426+
"metadata": {
427+
"tags": []
428+
},
429+
"outputs": [
430+
{
431+
"data": {
432+
"text/plain": [
433+
"[0, 1, 4, 9, 16, 25, 36, 49, 64, 81]"
434+
]
435+
},
436+
"execution_count": 26,
437+
"metadata": {},
438+
"output_type": "execute_result"
439+
}
440+
],
441+
"source": [
442+
"squares"
443+
]
444+
},
445+
{
446+
"cell_type": "markdown",
447+
"metadata": {},
448+
"source": [
449+
"````{admonition} Quick Exercise\n",
450+
"\n",
451+
"Use a list comprehension to create a new list from `squares` containing only the even numbers. It might be helpful to use the modulus operator, `%`\n",
452+
"\n",
453+
"````"
454+
]
455+
},
386456
{
387457
"cell_type": "code",
388458
"execution_count": null,
@@ -407,7 +477,7 @@
407477
"name": "python",
408478
"nbconvert_exporter": "python",
409479
"pygments_lexer": "ipython3",
410-
"version": "3.11.6"
480+
"version": "3.13.1"
411481
}
412482
},
413483
"nbformat": 4,

0 commit comments

Comments
 (0)