Skip to content

Commit a1bbe58

Browse files
committed
Update documentation
1 parent 2c17fdc commit a1bbe58

File tree

5 files changed

+40
-28
lines changed

5 files changed

+40
-28
lines changed

_sources/chap09.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1275,7 +1275,7 @@
12751275
"id": "f90bd9ea",
12761276
"metadata": {},
12771277
"source": [
1278-
"The result it a list.\n",
1278+
"The result is a list.\n",
12791279
"To convert the list to a string, we can use `join`."
12801280
]
12811281
},

_sources/chap10.ipynb

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -641,7 +641,7 @@
641641
"metadata": {},
642642
"source": [
643643
"The following function loops through the words in the list.\n",
644-
"For each one, it reverses the letters and then checks whether the reversed word in the word list."
644+
"For each one, it reverses the letters and then checks whether the reversed word is in the word list."
645645
]
646646
},
647647
{
@@ -669,6 +669,19 @@
669669
"If it doesn't find what it's looking for -- which happens most of the time -- it has to search all the way to the end."
670670
]
671671
},
672+
{
673+
"cell_type": "markdown",
674+
"id": "fac41347",
675+
"metadata": {
676+
"tags": [
677+
"remove-cell"
678+
]
679+
},
680+
"source": [
681+
"To measure how long a function takes, we can use `%time` which is one of Jupyter's \"built-in magic commands\".\n",
682+
"These commands are not part of the Python language, so they might not work in other development environments."
683+
]
684+
},
672685
{
673686
"cell_type": "code",
674687
"execution_count": 58,
@@ -767,6 +780,15 @@
767780
"This function takes less than one hundredth of a second, so it's about 10,000 times faster than the previous version."
768781
]
769782
},
783+
{
784+
"cell_type": "markdown",
785+
"id": "4cd91c99",
786+
"metadata": {},
787+
"source": [
788+
"In general, the time it takes to find an element in a list is proportional to the length of the list.\n",
789+
"The time it takes to find a key in a dictionary is almost constant -- regardless of the number of items."
790+
]
791+
},
770792
{
771793
"cell_type": "code",
772794
"execution_count": 62,
@@ -800,15 +822,6 @@
800822
"%time much_faster()"
801823
]
802824
},
803-
{
804-
"cell_type": "markdown",
805-
"id": "4cd91c99",
806-
"metadata": {},
807-
"source": [
808-
"In general, the time it takes to find an element in a list is proportional to the length of the list.\n",
809-
"The time it takes to find a key in a dictionary is almost constant -- regardless of the number of items."
810-
]
811-
},
812825
{
813826
"cell_type": "markdown",
814827
"id": "b3bfa8a5",
@@ -1539,19 +1552,6 @@
15391552
"In the notebook for this chapter, you'll see where these measurements come from."
15401553
]
15411554
},
1542-
{
1543-
"cell_type": "markdown",
1544-
"id": "c6f39f84",
1545-
"metadata": {
1546-
"tags": [
1547-
"remove-cell"
1548-
]
1549-
},
1550-
"source": [
1551-
"To measure how long a function takes, we can use `%time` which is one of Jupyter's \"built-in magic commands\".\n",
1552-
"These commands are not part of the Python language, so they might not work in other development environments."
1553-
]
1554-
},
15551555
{
15561556
"cell_type": "code",
15571557
"execution_count": 50,
@@ -2283,7 +2283,8 @@
22832283
"id": "e04a5c73",
22842284
"metadata": {
22852285
"tags": [
2286-
"remove-cell"
2286+
"remove-output",
2287+
"remove-print"
22872288
]
22882289
},
22892290
"outputs": [

chap09.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -962,7 +962,7 @@ <h2><span class="section-number">9.8. </span>Sorting lists<a class="headerlink"
962962
</div>
963963
</div>
964964
</div>
965-
<p>The result it a list.
965+
<p>The result is a list.
966966
To convert the list to a string, we can use <code class="docutils literal notranslate"><span class="pre">join</span></code>.</p>
967967
<div class="cell docutils container">
968968
<div class="cell_input docutils container">

chap10.html

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,7 @@ <h2><span class="section-number">10.2. </span>Creating dictionaries<a class="hea
648648
</div>
649649
</div>
650650
<p>The following function loops through the words in the list.
651-
For each one, it reverses the letters and then checks whether the reversed word in the word list.</p>
651+
For each one, it reverses the letters and then checks whether the reversed word is in the word list.</p>
652652
<div class="cell docutils container">
653653
<div class="cell_input docutils container">
654654
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">def</span> <span class="nf">too_slow</span><span class="p">():</span>
@@ -1240,6 +1240,17 @@ <h3><span class="section-number">10.11.6. </span>Exercise<a class="headerlink" h
12401240
</div>
12411241
</div>
12421242
<p>Write a function called <code class="docutils literal notranslate"><span class="pre">is_interlocking</span></code> that takes a word as an argument and returns <code class="docutils literal notranslate"><span class="pre">True</span></code> if it can be split into two interlocking words.</p>
1243+
<div class="cell tag_remove-output tag_remove-print docutils container">
1244+
<div class="cell_input docutils container">
1245+
<div class="highlight-ipython3 notranslate"><div class="highlight"><pre><span></span><span class="k">for</span> <span class="n">word</span> <span class="ow">in</span> <span class="n">word_list</span><span class="p">:</span>
1246+
<span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">word</span><span class="p">)</span> <span class="o">&gt;=</span> <span class="mi">8</span> <span class="ow">and</span> <span class="n">is_interlocking</span><span class="p">(</span><span class="n">word</span><span class="p">):</span>
1247+
<span class="n">first</span> <span class="o">=</span> <span class="n">word</span><span class="p">[</span><span class="mi">0</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span>
1248+
<span class="n">second</span> <span class="o">=</span> <span class="n">word</span><span class="p">[</span><span class="mi">1</span><span class="p">::</span><span class="mi">2</span><span class="p">]</span>
1249+
<span class="nb">print</span><span class="p">(</span><span class="n">word</span><span class="p">,</span> <span class="n">first</span><span class="p">,</span> <span class="n">second</span><span class="p">)</span>
1250+
</pre></div>
1251+
</div>
1252+
</div>
1253+
</div>
12431254
<p><a class="reference external" href="https://allendowney.github.io/ThinkPython/index.html">Think Python: 3rd Edition</a></p>
12441255
<p>Copyright 2024 <a class="reference external" href="https://allendowney.com">Allen B. Downey</a></p>
12451256
<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)