Skip to content

Commit

Permalink
some updates + allow errors
Browse files Browse the repository at this point in the history
  • Loading branch information
zingale committed Jan 16, 2024
1 parent 303d8fe commit fabc3b0
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 63 deletions.
24 changes: 9 additions & 15 deletions content/01-python/w2-python-advanced-datatypes.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-warning\">\n",
" \n",
"<span class=\"fa fa-flash\"></span> Quick Exercise:\n",
"````{admonition} Quick Exercise\n",
"\n",
"An operation we'll see a lot is to begin with an empty list and add elements to it. An empty list is created as:\n",
"```\n",
Expand All @@ -326,7 +324,7 @@
" * Append the integers 1 through 10 to it. \n",
" * Now pop them out of the list one by one.\n",
" \n",
"</div>"
"````"
]
},
{
Expand Down Expand Up @@ -438,7 +436,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"140401612860224 140401612860224 140401630932352\n"
"139748084686592 139748084686592 139748084800512\n"
]
}
],
Expand Down Expand Up @@ -746,13 +744,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-warning\">\n",
" \n",
"<span class=\"fa fa-flash\"></span> Quick Exercise:\n",
"````{admonition} Quick Exercise\n",
"\n",
"Create a dictionary where the keys are the string names of the numbers zero to nine and the values are their numeric representation (0, 1, ... , 9)\n",
"\n",
"</div>"
"````"
]
},
{
Expand Down Expand Up @@ -840,13 +836,11 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-warning\">\n",
" \n",
"<span class=\"fa fa-flash\"></span> Quick Exercise:\n",
"````{admonition} Quick Exercise\n",
"\n",
"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",
"\n",
"</div>"
"````"
]
},
{
Expand Down Expand Up @@ -950,7 +944,7 @@
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mTypeError\u001b[0m Traceback (most recent call last)",
"Input \u001b[0;32mIn [32]\u001b[0m, in \u001b[0;36m<cell line: 1>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0m a[\u001b[38;5;241m0\u001b[39m] \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m2\u001b[39m\n",
"Cell \u001b[0;32mIn[32], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[43ma\u001b[49m\u001b[43m[\u001b[49m\u001b[38;5;241;43m0\u001b[39;49m\u001b[43m]\u001b[49m \u001b[38;5;241m=\u001b[39m \u001b[38;5;241m2\u001b[39m\n",
"\u001b[0;31mTypeError\u001b[0m: 'tuple' object does not support item assignment"
]
}
Expand Down Expand Up @@ -1095,7 +1089,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
18 changes: 7 additions & 11 deletions content/01-python/w2-python-control-flow.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": 1,
"metadata": {},
"outputs": [
{
Expand All @@ -284,7 +284,7 @@
"my_dict = {\"key1\":1, \"key2\":2, \"key3\":3}\n",
"\n",
"for k, v in my_dict.items():\n",
" print(\"key = {}, value = {}\".format(k, v)) # notice how we do the formatting here\n"
" print(f\"key = {k}, value = {v}\")"
]
},
{
Expand Down Expand Up @@ -339,9 +339,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-warning\">\n",
" \n",
"<span class=\"fa fa-flash\"></span> Quick Exercise:\n",
"````{admonition} Quick Exercise\n",
" \n",
"`zip()` allows us to loop over two iterables at the same time. Consider the following two\n",
"lists:\n",
Expand All @@ -357,7 +355,7 @@
"\n",
"Try looping over these lists together (using `zip()`) and print the corresponding elements from each list together on a single line.\n",
"\n",
"</div>"
"````"
]
},
{
Expand All @@ -371,9 +369,7 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"<div class=\"alert alert-block alert-warning\">\n",
" \n",
"<span class=\"fa fa-flash\"></span> Quick Exercise:\n",
"````{admonition} Quick Exercise\n",
" \n",
"\n",
"The `.split()` function on a string can split it into words (separating on spaces). \n",
Expand All @@ -384,7 +380,7 @@
"\n",
"and print one word per line\n",
"\n",
"</div>"
"````"
]
},
{
Expand All @@ -411,7 +407,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.9"
"version": "3.11.6"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit fabc3b0

Please sign in to comment.