Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenDowney committed Aug 20, 2024
1 parent 66f906a commit 34be2b2
Show file tree
Hide file tree
Showing 128 changed files with 5,202 additions and 4,158 deletions.
2 changes: 1 addition & 1 deletion .buildinfo
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 8527eb75b0648988e85e921d1c5b10d6
config: 5abbffab39b66711a1b5944e737b7438
tags: 645f666f9bcd5a90fca523b33c5a78b7
12 changes: 2 additions & 10 deletions _sources/chap00.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@
"cells": [
{
"cell_type": "markdown",
"id": "b112e25b",
"id": "1331faa1",
"metadata": {},
"source": [
"You can order print and electronic versions of *Think Python 3e* from\n",
"You can order print and ebook versions of *Think Python 3e* from\n",
"[Bookshop.org](https://bookshop.org/a/98697/9781098155438) and\n",
"[Amazon](https://www.amazon.com/_/dp/1098155432?smid=ATVPDKIKX0DER&_encoding=UTF8&tag=oreilly20-20&_encoding=UTF8&tag=greenteapre01-20&linkCode=ur2&linkId=e2a529f94920295d27ec8a06e757dc7c&camp=1789&creative=9325)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3466e1f6",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "d9724920",
Expand Down
14 changes: 3 additions & 11 deletions _sources/chap01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@
"cells": [
{
"cell_type": "markdown",
"id": "b112e25b",
"id": "1331faa1",
"metadata": {},
"source": [
"You can order print and electronic versions of *Think Python 3e* from\n",
"You can order print and ebook versions of *Think Python 3e* from\n",
"[Bookshop.org](https://bookshop.org/a/98697/9781098155438) and\n",
"[Amazon](https://www.amazon.com/_/dp/1098155432?smid=ATVPDKIKX0DER&_encoding=UTF8&tag=oreilly20-20&_encoding=UTF8&tag=greenteapre01-20&linkCode=ur2&linkId=e2a529f94920295d27ec8a06e757dc7c&camp=1789&creative=9325)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3466e1f6",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "markdown",
"id": "a14edb7e",
Expand Down Expand Up @@ -1812,7 +1804,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.10.11"
}
},
"nbformat": 4,
Expand Down
17 changes: 4 additions & 13 deletions _sources/chap02.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@
"cells": [
{
"cell_type": "markdown",
"id": "b112e25b",
"id": "1331faa1",
"metadata": {},
"source": [
"You can order print and electronic versions of *Think Python 3e* from\n",
"You can order print and ebook versions of *Think Python 3e* from\n",
"[Bookshop.org](https://bookshop.org/a/98697/9781098155438) and\n",
"[Amazon](https://www.amazon.com/_/dp/1098155432?smid=ATVPDKIKX0DER&_encoding=UTF8&tag=oreilly20-20&_encoding=UTF8&tag=greenteapre01-20&linkCode=ur2&linkId=e2a529f94920295d27ec8a06e757dc7c&camp=1789&creative=9325)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3466e1f6",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 1,
Expand Down Expand Up @@ -1356,7 +1348,6 @@
"\n",
"**argument:**\n",
"A value provided to a function when the function is called.\n",
"Each argument is assigned to the corresponding parameter in the function.\n",
"\n",
"**comment:**\n",
"Text included in a program that provides information about the program but has no effect on its execution.\n",
Expand Down Expand Up @@ -1409,7 +1400,7 @@
"\n",
"You might have noticed that `int`, `float`, and `str` are not Python keywords.\n",
"They are variables that represent types, and they can be used as functions.\n",
"So it is *legal* to have a variable or function with one of those names, but it is strongly discouraged. Ask an assistant \"Why is it bad to use int, float, and string as variable names?\"\n",
"So it is *legal* to have a variable or function with one of those names, but it is strongly discouraged. Ask an assistant \"Why is it bad to use int, float, and str as variable names?\"\n",
"\n",
"Also ask, \"What are the built-in functions in Python?\"\n",
"If you are curious about any of them, ask for more information.\n",
Expand Down Expand Up @@ -1601,7 +1592,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.10.11"
},
"vscode": {
"interpreter": {
Expand Down
16 changes: 4 additions & 12 deletions _sources/chap03.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@
"cells": [
{
"cell_type": "markdown",
"id": "b112e25b",
"id": "1331faa1",
"metadata": {},
"source": [
"You can order print and electronic versions of *Think Python 3e* from\n",
"You can order print and ebook versions of *Think Python 3e* from\n",
"[Bookshop.org](https://bookshop.org/a/98697/9781098155438) and\n",
"[Amazon](https://www.amazon.com/_/dp/1098155432?smid=ATVPDKIKX0DER&_encoding=UTF8&tag=oreilly20-20&_encoding=UTF8&tag=greenteapre01-20&linkCode=ur2&linkId=e2a529f94920295d27ec8a06e757dc7c&camp=1789&creative=9325)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3466e1f6",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 1,
Expand Down Expand Up @@ -517,7 +509,7 @@
"The first line is a header that ends with a colon.\n",
"The second line is the body, which has to be indented.\n",
"\n",
"The first line starts with the keyword `for`, a new variable named `i`, and another keyword, `in`. \n",
"The header starts with the keyword `for`, a new variable named `i`, and another keyword, `in`. \n",
"It uses the `range` function to create a sequence of two values, which are `0` and `1`.\n",
"In Python, when we start counting, we usually start from `0`.\n",
"\n",
Expand Down Expand Up @@ -1787,7 +1779,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.10.11"
}
},
"nbformat": 4,
Expand Down
15 changes: 3 additions & 12 deletions _sources/chap04.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@
"cells": [
{
"cell_type": "markdown",
"id": "b112e25b",
"id": "1331faa1",
"metadata": {},
"source": [
"You can order print and electronic versions of *Think Python 3e* from\n",
"You can order print and ebook versions of *Think Python 3e* from\n",
"[Bookshop.org](https://bookshop.org/a/98697/9781098155438) and\n",
"[Amazon](https://www.amazon.com/_/dp/1098155432?smid=ATVPDKIKX0DER&_encoding=UTF8&tag=oreilly20-20&_encoding=UTF8&tag=greenteapre01-20&linkCode=ur2&linkId=e2a529f94920295d27ec8a06e757dc7c&camp=1789&creative=9325)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3466e1f6",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 1,
Expand Down Expand Up @@ -1258,7 +1250,6 @@
"\n",
"2. Once you get the program working, identify a coherent piece of it,\n",
" encapsulate the piece in a function and give it a name.\n",
" Copy and paste working code to avoid retyping (and re-debugging).\n",
"\n",
"3. Generalize the function by adding appropriate parameters.\n",
"\n",
Expand Down Expand Up @@ -7915,7 +7906,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.10.11"
}
},
"nbformat": 4,
Expand Down
94 changes: 56 additions & 38 deletions _sources/chap05.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@
"cells": [
{
"cell_type": "markdown",
"id": "b112e25b",
"id": "1331faa1",
"metadata": {},
"source": [
"You can order print and electronic versions of *Think Python 3e* from\n",
"You can order print and ebook versions of *Think Python 3e* from\n",
"[Bookshop.org](https://bookshop.org/a/98697/9781098155438) and\n",
"[Amazon](https://www.amazon.com/_/dp/1098155432?smid=ATVPDKIKX0DER&_encoding=UTF8&tag=oreilly20-20&_encoding=UTF8&tag=greenteapre01-20&linkCode=ur2&linkId=e2a529f94920295d27ec8a06e757dc7c&camp=1789&creative=9325)."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "3466e1f6",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 1,
Expand Down Expand Up @@ -101,8 +93,8 @@
"id": "3f224403",
"metadata": {},
"source": [
"But we don't normally write hours with decimal points. Floor division\n",
"returns the integer number of hours, rounding down:"
"But we don't normally write hours with decimal points.\n",
"Integer division returns the integer number of hours, rounding down:"
]
},
{
Expand Down Expand Up @@ -190,73 +182,99 @@
},
{
"cell_type": "markdown",
"id": "f2344fc0",
"id": "18c1e0d0",
"metadata": {},
"source": [
"The modulus operator is more useful than it might seem.\n",
"For example, it can check whether one number is divisible by another -- if `x % y` is zero, then `x` is divisible by `y`.\n",
"\n",
"Also, it can extract the right-most digit or digits from a number.\n",
"For example, `x % 10` yields the right-most digit of `x` (in base 10).\n",
"Similarly, `x % 100` yields the last two digits.\n",
"\n",
"Finally, the modulus operator can do \"clock arithmetic\".\n",
"For example, if an event starts at 11 AM and lasts three hours, we can use the modulus operator to figure out what time it ends."
"Similarly, `x % 100` yields the last two digits."
]
},
{
"cell_type": "code",
"execution_count": 6,
"id": "db33a44d",
"execution_count": 2,
"id": "5bd341f7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2"
"3"
]
},
"execution_count": 6,
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"start = 11\n",
"duration = 3\n",
"end = (start + duration) % 12\n",
"end"
"x = 123\n",
"x % 10"
]
},
{
"cell_type": "code",
"execution_count": 3,
"id": "367fce0c",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"23"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x % 100"
]
},
{
"cell_type": "markdown",
"id": "351c30df",
"id": "f2344fc0",
"metadata": {},
"source": [
"The event would end at 2 PM."
"Finally, the modulus operator can do \"clock arithmetic\".\n",
"For example, if an event starts at 11 AM and lasts three hours, we can use the modulus operator to figure out what time it ends."
]
},
{
"cell_type": "code",
"execution_count": 7,
"id": "367fce0c",
"execution_count": 6,
"id": "db33a44d",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"(2, 5)"
"2"
]
},
"execution_count": 7,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"a = 25 // 10\n",
"b = 25 % 10\n",
"a, b"
"start = 11\n",
"duration = 3\n",
"end = (start + duration) % 12\n",
"end"
]
},
{
"cell_type": "markdown",
"id": "351c30df",
"metadata": {},
"source": [
"The event would end at 2 PM."
]
},
{
Expand Down Expand Up @@ -1615,7 +1633,7 @@
"metadata": {},
"source": [
"The error message indicates line 5, but there is nothing wrong with that line.\n",
"The problem is in line 4, which uses floor division instead of floating-point division -- as a result, the value of `ratio` is `0`.\n",
"The problem is in line 4, which uses integer division instead of floating-point division -- as a result, the value of `ratio` is `0`.\n",
"When we call `math.log10`, we get a `ValueError` with the message `math domain error`, because `0` is not in the \"domain\" of valid arguments for `math.log10`, because the logarithm of `0` is undefined.\n",
"\n",
"In general, you should take the time to read error messages carefully, but don't assume that everything they say is correct."
Expand Down Expand Up @@ -1919,7 +1937,7 @@
"id": "054c3197",
"metadata": {},
"source": [
"Use floor division and the modulus operator to compute the number of days since January 1, 1970 and the current time of day in hours, minutes, and seconds."
"Use integer division and the modulus operator to compute the number of days since January 1, 1970 and the current time of day in hours, minutes, and seconds."
]
},
{
Expand Down Expand Up @@ -2444,7 +2462,7 @@
"\n",
"The exception is if `x` is less than `5` -- in that case, you can just draw a straight line with length `x`.\n",
"\n",
"Write a function called `koch` that takes `x` as a parameter and draws a Koch curve with the given length.\n"
"Write a function called `koch` that takes `x` as an argument and draws a Koch curve with the given length.\n"
]
},
{
Expand Down Expand Up @@ -3419,7 +3437,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.10.14"
"version": "3.10.11"
}
},
"nbformat": 4,
Expand Down
Loading

0 comments on commit 34be2b2

Please sign in to comment.