Skip to content

Commit d7dcc34

Browse files
committed
Update documentation
1 parent a1e72c1 commit d7dcc34

File tree

6 files changed

+51
-34
lines changed

6 files changed

+51
-34
lines changed
19.7 KB
Loading

_sources/chap03.ipynb

Lines changed: 7 additions & 7 deletions
Large diffs are not rendered by default.

_sources/chap07.ipynb

Lines changed: 27 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -78268,7 +78268,13 @@
7826878268
"protracted\n",
7826978269
"protracting\n",
7827078270
"protractor\n",
78271-
"protractors\n",
78271+
"protractors\n"
78272+
]
78273+
},
78274+
{
78275+
"name": "stdout",
78276+
"output_type": "stream",
78277+
"text": [
7827278278
"protracts\n",
7827378279
"protrude\n",
7827478280
"protruded\n",
@@ -115678,6 +115684,7 @@
115678115684
"source": [
115679115685
"available = 'ACDLORT'\n",
115680115686
"required = 'R'\n",
115687+
"\n",
115681115688
"total = 0\n",
115682115689
"\n",
115683115690
"file_object = open('words.txt')\n",
@@ -115820,32 +115827,27 @@
115820115827
{
115821115828
"cell_type": "code",
115822115829
"execution_count": 71,
115830+
"id": "a3ea747d",
115831+
"metadata": {},
115832+
"outputs": [],
115833+
"source": [
115834+
"# Here's what I got from ChatGPT 4o December 26, 2024\n",
115835+
"# It's correct, but it makes multiple calls to uses_any \n",
115836+
"\n",
115837+
"def uses_all(s1, s2):\n",
115838+
" \"\"\"Checks if all characters in s2 are in s1, allowing repeats.\"\"\"\n",
115839+
" for char in s2:\n",
115840+
" if not uses_any(s1, char):\n",
115841+
" return False\n",
115842+
" return True\n"
115843+
]
115844+
},
115845+
{
115846+
"cell_type": "code",
115847+
"execution_count": 72,
115823115848
"id": "6980de57",
115824115849
"metadata": {},
115825-
"outputs": [
115826-
{
115827-
"name": "stdout",
115828-
"output_type": "stream",
115829-
"text": [
115830-
"**********************************************************************\n",
115831-
"File \"__main__\", line 11, in uses_all\n",
115832-
"Failed example:\n",
115833-
" uses_all('banana', 'ban')\n",
115834-
"Expected:\n",
115835-
" True\n",
115836-
"Got:\n",
115837-
" False\n",
115838-
"**********************************************************************\n",
115839-
"File \"__main__\", line 13, in uses_all\n",
115840-
"Failed example:\n",
115841-
" uses_all('ratatat', 'rat')\n",
115842-
"Expected:\n",
115843-
" True\n",
115844-
"Got:\n",
115845-
" False\n"
115846-
]
115847-
}
115848-
],
115850+
"outputs": [],
115849115851
"source": []
115850115852
},
115851115853
{

chap03.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -757,7 +757,7 @@ <h2><span class="section-number">3.6. </span>Stack diagrams<a class="headerlink"
757757
<p>Here’s the stack diagram for the previous example.</p>
758758
<div class="cell tag_remove-input tag_keep docutils container">
759759
<div class="cell_output docutils container">
760-
<img alt="_images/4203fc81cc8d5aa986a00dafa5e0a563fbc55ef01723367c46fda7d7b1dee11c.png" src="_images/4203fc81cc8d5aa986a00dafa5e0a563fbc55ef01723367c46fda7d7b1dee11c.png" />
760+
<img alt="_images/02b6ddc296c3c51396cc7c1a916aa9f4ea1bc5ed61b9fe10d6ec63e9b928fc68.png" src="_images/02b6ddc296c3c51396cc7c1a916aa9f4ea1bc5ed61b9fe10d6ec63e9b928fc68.png" />
761761
</div>
762762
</div>
763763
<p>The frames are arranged in a stack that indicates which function called

chap07.html

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1245,6 +1245,21 @@ <h3><span class="section-number">7.9.8. </span>Exercise<a class="headerlink" hre
12451245
<p>Now let’s see if we can write <code class="docutils literal notranslate"><span class="pre">uses_all</span></code> based on <code class="docutils literal notranslate"><span class="pre">uses_any</span></code>.</p>
12461246
<p>Ask a virtual assistant, “Given a function, <code class="docutils literal notranslate"><span class="pre">uses_any</span></code>, which takes two strings and checks whether the first uses any of the letters in the second, can you use it to write <code class="docutils literal notranslate"><span class="pre">uses_all</span></code>, which takes two strings and checks whether the first uses all the letters in the second, allowing repeats.”</p>
12471247
<p>If it says it can, be sure to test the result!</p>
1248+
<div class="cell docutils container">
1249+
<div class="cell_input docutils container">
1250+
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="c1"># Here&#39;s what I got from ChatGPT 4o December 26, 2024</span>
1251+
<span class="c1"># It&#39;s correct, but it makes multiple calls to uses_any </span>
1252+
1253+
<span class="k">def</span> <span class="nf">uses_all</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">s2</span><span class="p">):</span>
1254+
<span class="w"> </span><span class="sd">&quot;&quot;&quot;Checks if all characters in s2 are in s1, allowing repeats.&quot;&quot;&quot;</span>
1255+
<span class="k">for</span> <span class="n">char</span> <span class="ow">in</span> <span class="n">s2</span><span class="p">:</span>
1256+
<span class="k">if</span> <span class="ow">not</span> <span class="n">uses_any</span><span class="p">(</span><span class="n">s1</span><span class="p">,</span> <span class="n">char</span><span class="p">):</span>
1257+
<span class="k">return</span> <span class="kc">False</span>
1258+
<span class="k">return</span> <span class="kc">True</span>
1259+
</pre></div>
1260+
</div>
1261+
</div>
1262+
</div>
12481263
<p><a class="reference external" href="https://allendowney.github.io/ThinkPython/index.html">Think Python: 3rd Edition</a></p>
12491264
<p>Copyright 2024 <a class="reference external" href="https://allendowney.com">Allen B. Downey</a></p>
12501265
<p>Code license: <a class="reference external" href="https://mit-license.org/">MIT License</a></p>

searchindex.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)