Skip to content

Commit

Permalink
Update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
AllenDowney committed May 8, 2024
1 parent 765e526 commit d7fa947
Show file tree
Hide file tree
Showing 29 changed files with 226 additions and 215 deletions.
1 change: 1 addition & 0 deletions _sources/chap01.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@
]
},
"source": [
"(chapter_programming)=\n",
"(chapter_programming)=\n",
"# Programming as a way of thinking\n",
"\n",
Expand Down
3 changes: 3 additions & 0 deletions _sources/chap04.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
]
},
"source": [
"(section_turtle_module)=\n",
"(section_turtle_module)=\n",
"## The jupyturtle module\n",
"\n",
Expand Down Expand Up @@ -389,6 +390,7 @@
]
},
"source": [
"(section_encapsulation)=\n",
"(section_encapsulation)=\n",
"## Encapsulation and generalization\n",
"\n",
Expand Down Expand Up @@ -1318,6 +1320,7 @@
]
},
"source": [
"(section_docstring)=\n",
"(section_docstring)=\n",
"## Docstrings\n",
"\n",
Expand Down
3 changes: 3 additions & 0 deletions _sources/chap06.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -640,6 +640,7 @@
]
},
"source": [
"(section_incremental)=\n",
"(section_incremental)=\n",
"## Incremental development\n",
"\n",
Expand Down Expand Up @@ -1355,6 +1356,7 @@
]
},
"source": [
"(section_fibonacci)=\n",
"(section_fibonacci)=\n",
"## Fibonacci\n",
"\n",
Expand Down Expand Up @@ -1592,6 +1594,7 @@
]
},
"source": [
"(section_debugging_factorial)=\n",
"(section_debugging_factorial)=\n",
"## Debugging\n",
"\n",
Expand Down
1 change: 1 addition & 0 deletions _sources/chap07.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
]
},
"source": [
"(chapter_search)=\n",
"(chapter_search)=\n",
"# Iteration and Search\n",
"\n",
Expand Down
1 change: 1 addition & 0 deletions _sources/chap08.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -847,6 +847,7 @@
]
},
"source": [
"(section_writing_files)=\n",
"(section_writing_files)=\n",
"## Writing files\n",
"\n",
Expand Down
1 change: 1 addition & 0 deletions _sources/chap09.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1830,6 +1830,7 @@
]
},
"source": [
"(section_word_list)=\n",
"(section_word_list)=\n",
"## Making a word list\n",
"\n",
Expand Down
3 changes: 3 additions & 0 deletions _sources/chap10.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@
]
},
"source": [
"(section_dictionary_in_operator)=\n",
"(section_dictionary_in_operator)=\n",
"## The in operator\n",
"\n",
Expand Down Expand Up @@ -1193,6 +1194,7 @@
]
},
"source": [
"(section_palindrome_list)=\n",
"(section_palindrome_list)=\n",
"## Accumulating a list\n",
"\n",
Expand Down Expand Up @@ -1356,6 +1358,7 @@
]
},
"source": [
"(section_memos)=\n",
"(section_memos)=\n",
"## Memos\n",
"\n",
Expand Down
9 changes: 5 additions & 4 deletions _sources/chap11.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
]
},
"source": [
"(chapter_tuples)=\n",
"(chapter_tuples)=\n",
"# Tuples\n",
"\n",
Expand Down Expand Up @@ -1037,6 +1038,7 @@
]
},
"source": [
"(section_argument_pack)=\n",
"(section_argument_pack)=\n",
"## Argument packing\n",
"\n",
Expand Down Expand Up @@ -1942,6 +1944,7 @@
]
},
"source": [
"(section_debugging_11)=\n",
"(section_debugging_11)=\n",
"## Debugging\n",
"\n",
Expand Down Expand Up @@ -2309,10 +2312,7 @@
]
}
],
"source": [
"\n",
"d = {t: 'this tuple contains two lists'}"
]
"source": []
},
{
"cell_type": "markdown",
Expand All @@ -2331,6 +2331,7 @@
]
},
"source": [
"(section_exercise_11)=\n",
"(section_exercise_11)=\n",
"### Exercise\n",
"\n",
Expand Down
2 changes: 2 additions & 0 deletions _sources/chap12.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -853,6 +853,7 @@
]
},
"source": [
"(section_dictionary_subtraction)=\n",
"(section_dictionary_subtraction)=\n",
"## Dictionary subtraction\n",
"\n",
Expand Down Expand Up @@ -2119,6 +2120,7 @@
]
},
"source": [
"(section_debugging_12)=\n",
"(section_debugging_12)=\n",
"## Debugging\n",
"\n",
Expand Down
3 changes: 3 additions & 0 deletions _sources/chap13.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1293,6 +1293,7 @@
]
},
"source": [
"(section_storing_data_structure)=\n",
"(section_storing_data_structure)=\n",
"## Storing data structures\n",
"\n",
Expand Down Expand Up @@ -1560,6 +1561,7 @@
]
},
"source": [
"(section_md5_digest)=\n",
"(section_md5_digest)=\n",
"## Checking for equivalent files\n",
"\n",
Expand Down Expand Up @@ -1812,6 +1814,7 @@
]
},
"source": [
"(section_walking_directories)=\n",
"(section_walking_directories)=\n",
"## Walking directories\n",
"\n",
Expand Down
1 change: 1 addition & 0 deletions _sources/chap14.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -1377,6 +1377,7 @@
]
},
"source": [
"(section_debugging_14)=\n",
"(section_debugging_14)=\n",
"## Debugging\n",
"\n",
Expand Down
1 change: 1 addition & 0 deletions _sources/chap16.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
]
},
"source": [
"(section_create_point)=\n",
"(section_create_point)=\n",
"## Creating a Point\n",
"\n",
Expand Down
2 changes: 2 additions & 0 deletions _sources/chap17.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
]
},
"source": [
"(chapter_inheritance)=\n",
"(chapter_inheritance)=\n",
"# Inheritance\n",
"\n",
Expand Down Expand Up @@ -1046,6 +1047,7 @@
]
},
"source": [
"(section_print_deck)=\n",
"(section_print_deck)=\n",
"## Printing the deck\n",
"\n",
Expand Down
18 changes: 9 additions & 9 deletions chap01.html
Original file line number Diff line number Diff line change
Expand Up @@ -342,9 +342,9 @@ <h2> Contents </h2>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#exercises">Exercises</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#ask-a-virtual-assistant">Ask a virtual assistant</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#exercise">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id1">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id2">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id3">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id4">Exercise</a></li>
</ul>
</li>
</ul>
Expand All @@ -359,7 +359,7 @@ <h2> Contents </h2>
<article class="bd-article" role="main">

<section id="programming-as-a-way-of-thinking">
<span id="chapter-programming"></span><h1>Programming as a way of thinking<a class="headerlink" href="#programming-as-a-way-of-thinking" title="Permalink to this heading">#</a></h1>
<span id="id1"></span><span id="chapter-programming"></span><h1>Programming as a way of thinking<a class="headerlink" href="#programming-as-a-way-of-thinking" title="Permalink to this heading">#</a></h1>
<p>The first goal of this book is to teach you how to program in Python.
But learning to program means learning a new way to think, so the second goal of this book is to help you think like a computer scientist.
This way of thinking combines some of the best features of mathematics, engineering, and natural science.
Expand Down Expand Up @@ -1061,8 +1061,8 @@ <h3>Exercise<a class="headerlink" href="#exercise" title="Permalink to this head
</div>
<p>If you are curious, ask a virtual assistant, “If a number ends in 0.5, does Python round up or down?”</p>
</section>
<section id="id1">
<h3>Exercise<a class="headerlink" href="#id1" title="Permalink to this heading">#</a></h3>
<section id="id2">
<h3>Exercise<a class="headerlink" href="#id2" title="Permalink to this heading">#</a></h3>
<p>When you learn about a new feature, you should try it out and make mistakes on purpose.
That way, you learn the error messages, and when you see them again, you will know what they mean.
It is better to make mistakes now and deliberately than later and accidentally.</p>
Expand All @@ -1072,8 +1072,8 @@ <h3>Exercise<a class="headerlink" href="#id1" title="Permalink to this heading">
<li><p>If you call a function like <code class="docutils literal notranslate"><span class="pre">round(42.5)</span></code>, what happens if you leave out one or both parentheses?</p></li>
</ol>
</section>
<section id="id2">
<h3>Exercise<a class="headerlink" href="#id2" title="Permalink to this heading">#</a></h3>
<section id="id3">
<h3>Exercise<a class="headerlink" href="#id3" title="Permalink to this heading">#</a></h3>
<p>Recall that every expression has a value, every value has a type, and we can use the <code class="docutils literal notranslate"><span class="pre">type</span></code> function to find the type of any value.</p>
<p>What is the type of the value of the following expressions? Make your best guess for each one, and then use <code class="docutils literal notranslate"><span class="pre">type</span></code> to find out.</p>
<ul class="simple">
Expand All @@ -1087,8 +1087,8 @@ <h3>Exercise<a class="headerlink" href="#id2" title="Permalink to this heading">
<li><p><code class="docutils literal notranslate"><span class="pre">type</span></code></p></li>
</ul>
</section>
<section id="id3">
<h3>Exercise<a class="headerlink" href="#id3" title="Permalink to this heading">#</a></h3>
<section id="id4">
<h3>Exercise<a class="headerlink" href="#id4" title="Permalink to this heading">#</a></h3>
<p>The following questions give you a chance to practice writing arithmetic expressions.</p>
<ol class="arabic simple">
<li><p>How many seconds are there in 42 minutes 42 seconds?</p></li>
Expand Down Expand Up @@ -1181,9 +1181,9 @@ <h3>Exercise<a class="headerlink" href="#id3" title="Permalink to this heading">
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#exercises">Exercises</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#ask-a-virtual-assistant">Ask a virtual assistant</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#exercise">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id1">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id2">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id3">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id4">Exercise</a></li>
</ul>
</li>
</ul>
Expand Down
38 changes: 19 additions & 19 deletions chap04.html
Original file line number Diff line number Diff line change
Expand Up @@ -345,10 +345,10 @@ <h2> Contents </h2>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#exercise">Exercise</a></li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#id1">Exercise</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id2">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id3">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id4">Exercise</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#id4">Exercise</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id5">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id6">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id7">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#ask-a-virtual-assistant">Ask a virtual assistant</a></li>
</ul>
</li>
Expand All @@ -368,7 +368,7 @@ <h1>Functions and Interfaces<a class="headerlink" href="#functions-and-interface
<p>This chapter introduces a module called <code class="docutils literal notranslate"><span class="pre">jupyturtle</span></code>, which allows you to create simple drawings by giving instructions to an imaginary turtle.
We will use this module to write functions that draw squares, polygons, and circles – and to demonstrate <strong>interface design</strong>, which is a way of designing functions that work together.</p>
<section id="the-jupyturtle-module">
<span id="section-turtle-module"></span><h2>The jupyturtle module<a class="headerlink" href="#the-jupyturtle-module" title="Permalink to this heading">#</a></h2>
<span id="id1"></span><span id="section-turtle-module"></span><h2>The jupyturtle module<a class="headerlink" href="#the-jupyturtle-module" title="Permalink to this heading">#</a></h2>
<p>To use the <code class="docutils literal notranslate"><span class="pre">jupyturtle</span></code> module, we can import it like this.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
Expand Down Expand Up @@ -546,7 +546,7 @@ <h2>Making a square<a class="headerlink" href="#making-a-square" title="Permalin
</div>
</section>
<section id="encapsulation-and-generalization">
<span id="section-encapsulation"></span><h2>Encapsulation and generalization<a class="headerlink" href="#encapsulation-and-generalization" title="Permalink to this heading">#</a></h2>
<span id="id2"></span><span id="section-encapsulation"></span><h2>Encapsulation and generalization<a class="headerlink" href="#encapsulation-and-generalization" title="Permalink to this heading">#</a></h2>
<p>Let’s take the square-drawing code from the previous section and put it in a function called <code class="docutils literal notranslate"><span class="pre">square</span></code>.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
Expand Down Expand Up @@ -1108,7 +1108,7 @@ <h2>A development plan<a class="headerlink" href="#a-development-plan" title="Pe
<p>These two functions have the same interface – they take the same parameters and do the same thing – but they have different implementations.</p>
</section>
<section id="docstrings">
<span id="section-docstring"></span><h2>Docstrings<a class="headerlink" href="#docstrings" title="Permalink to this heading">#</a></h2>
<span id="id3"></span><span id="section-docstring"></span><h2>Docstrings<a class="headerlink" href="#docstrings" title="Permalink to this heading">#</a></h2>
<p>A <strong>docstring</strong> is a string at the beginning of a function that explains the interface (“doc” is short for “documentation”).
Here is an example:</p>
<div class="cell docutils container">
Expand Down Expand Up @@ -1239,8 +1239,8 @@ <h3>Exercise<a class="headerlink" href="#exercise" title="Permalink to this head
</div>
</section>
</section>
<section id="id1">
<h2>Exercise<a class="headerlink" href="#id1" title="Permalink to this heading">#</a></h2>
<section id="id4">
<h2>Exercise<a class="headerlink" href="#id4" title="Permalink to this heading">#</a></h2>
<p>Write a function called <code class="docutils literal notranslate"><span class="pre">rhombus</span></code> that draws a rhombus with a given side length and a given interior angle. For example, here’s a rhombus with side length <code class="docutils literal notranslate"><span class="pre">50</span></code> and an interior angle of <code class="docutils literal notranslate"><span class="pre">60</span></code> degrees.</p>
<div class="cell docutils container">
<div class="cell_input docutils container">
Expand Down Expand Up @@ -1275,8 +1275,8 @@ <h2>Exercise<a class="headerlink" href="#id1" title="Permalink to this heading">

</svg></div></div>
</div>
<section id="id2">
<h3>Exercise<a class="headerlink" href="#id2" title="Permalink to this heading">#</a></h3>
<section id="id5">
<h3>Exercise<a class="headerlink" href="#id5" title="Permalink to this heading">#</a></h3>
<p>Now write a more general function called <code class="docutils literal notranslate"><span class="pre">parallelogram</span></code> that draws a quadrilateral with parallel sides. Then rewrite <code class="docutils literal notranslate"><span class="pre">rectangle</span></code> and <code class="docutils literal notranslate"><span class="pre">rhombus</span></code> to use <code class="docutils literal notranslate"><span class="pre">parallelogram</span></code>.</p>
<div class="cell tag_remove-input docutils container">
<div class="cell_output docutils container">
Expand Down Expand Up @@ -1316,8 +1316,8 @@ <h3>Exercise<a class="headerlink" href="#id2" title="Permalink to this heading">
</svg></div></div>
</div>
</section>
<section id="id3">
<h3>Exercise<a class="headerlink" href="#id3" title="Permalink to this heading">#</a></h3>
<section id="id6">
<h3>Exercise<a class="headerlink" href="#id6" title="Permalink to this heading">#</a></h3>
<p>Write an appropriately general set of functions that can draw shapes like this.</p>
<p>Hint: Write a function called <code class="docutils literal notranslate"><span class="pre">triangle</span></code> that draws one triangular segment, and then a function called <code class="docutils literal notranslate"><span class="pre">draw_pie</span></code> that uses <code class="docutils literal notranslate"><span class="pre">triangle</span></code>.</p>
<div class="cell tag_remove-input docutils container">
Expand Down Expand Up @@ -1442,8 +1442,8 @@ <h3>Exercise<a class="headerlink" href="#id3" title="Permalink to this heading">
</svg></div></div>
</div>
</section>
<section id="id4">
<h3>Exercise<a class="headerlink" href="#id4" title="Permalink to this heading">#</a></h3>
<section id="id7">
<h3>Exercise<a class="headerlink" href="#id7" title="Permalink to this heading">#</a></h3>
<p>Write an appropriately general set of functions that can draw flowers like this.</p>
<p>Hint: Use <code class="docutils literal notranslate"><span class="pre">arc</span></code> to write a function called <code class="docutils literal notranslate"><span class="pre">petal</span></code> that draws one flower petal.</p>
<div class="cell tag_remove-input docutils container">
Expand Down Expand Up @@ -3497,10 +3497,10 @@ <h3>Ask a virtual assistant<a class="headerlink" href="#ask-a-virtual-assistant"
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#exercise">Exercise</a></li>
</ul>
</li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#id1">Exercise</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id2">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id3">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id4">Exercise</a></li>
<li class="toc-h2 nav-item toc-entry"><a class="reference internal nav-link" href="#id4">Exercise</a><ul class="nav section-nav flex-column">
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id5">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id6">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#id7">Exercise</a></li>
<li class="toc-h3 nav-item toc-entry"><a class="reference internal nav-link" href="#ask-a-virtual-assistant">Ask a virtual assistant</a></li>
</ul>
</li>
Expand Down
Loading

0 comments on commit d7fa947

Please sign in to comment.