Skip to content

Commit

Permalink
fix: multiple small fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonas-eschle committed Nov 5, 2024
1 parent 97c06da commit e702c29
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 63 deletions.
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,12 @@ _book/
node_modules/
*.pyc
*.swp

book.pdf
analysis-essentials.pdf
shell/files/data-shell.zip
build
.ipynb_checkpoints
*~
*~
/.idea

8 changes: 4 additions & 4 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ repos:


# needs rust, only activate if needed
- repo: https://github.com/shssoichiro/oxipng
rev: v9.1.2
hooks:
- id: oxipng
# - repo: https://github.com/shssoichiro/oxipng
# rev: v9.1.2
# hooks:
# - id: oxipng

12 changes: 12 additions & 0 deletions python/01basics.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"is_executing": true
},
"slideshow": {
"slide_type": "subslide"
}
Expand Down Expand Up @@ -129,6 +132,9 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"is_executing": true
},
"slideshow": {
"slide_type": "subslide"
}
Expand All @@ -155,6 +161,9 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"is_executing": true
},
"slideshow": {
"slide_type": "subslide"
}
Expand Down Expand Up @@ -1266,6 +1275,9 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"jupyter": {
"is_executing": true
},
"slideshow": {
"slide_type": "subslide"
}
Expand Down
2 changes: 1 addition & 1 deletion python/conditions.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@
"Find the double-underscore method on lists and dictionaries that corresponds to\n",
"the `in` operator, and check that it does the same thing as the operator.\n",
"\n",
"{% solution \"Solution\" %}\n",
"**Solutions**\n",
"\n",
"Taking lists as an example, the `dir` method can tell us what methods are\n",
"available. The `__contains__` method sounds promising."
Expand Down
32 changes: 7 additions & 25 deletions python/dictionaries.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -324,45 +324,27 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
"tags": [
"raises-exception"
]
},
"outputs": [],
"source": [
"dd[numbers] = 0"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"cell_type": "markdown",
"metadata": {},
"source": [
"In essence, keys must not be mutable. This includes numbers, strings, and\n",
"tuples, but not lists. This restriction is a trade-off that allows Python to\n",
"make accessing values in a dictionary by key very fast."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"cell_type": "markdown",
"metadata": {},
"source": [
"**Advanced (skip on first read)**\n",
"Immutable data types in Python have a `__hash__()` function, you can test it\n",
Expand Down
28 changes: 6 additions & 22 deletions python/lists.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -603,16 +603,8 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"cell_type": "markdown",
"metadata": {},
"source": [
"**Solution**\n",
"You need to slice from the very beginning to the very end of the list."
Expand Down Expand Up @@ -784,7 +776,7 @@
"outputs": [],
"source": [
"for i in b:\n",
"print(i)"
" print(i)"
]
},
{
Expand Down Expand Up @@ -817,7 +809,7 @@
"outputs": [],
"source": [
"for i in b:\n",
" print(\"I am in a loop\")\n",
" print(\"I am in a loop\")\n",
" print(i)"
]
},
Expand Down Expand Up @@ -1758,16 +1750,8 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"cell_type": "markdown",
"metadata": {},
"source": [
"Each element of the list is a tuple."
]
Expand Down
12 changes: 2 additions & 10 deletions python/numbers.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,8 @@
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"editable": true,
"slideshow": {
"slide_type": ""
},
"tags": []
},
"outputs": [],
"cell_type": "markdown",
"metadata": {},
"source": [
"Python also lets you manipulate complex numbers, using `j` to represent the \n",
"complex term."
Expand Down

0 comments on commit e702c29

Please sign in to comment.