77
88% \documentclass[10pt,b5paper]{book}
99\documentclass [10pt ]{book }
10- \usepackage [width=5.5in,height=8.5in,
11- hmarginratio=3:2,vmarginratio=1:1]{geometry}
10+ \usepackage [width=5.5in,height=8.5in,hmarginratio=3:2,vmarginratio=1:1 ]{geometry }
1211
1312% for some of these packages, you might have to install
1413% texlive-latex-extra (in Ubuntu)
3332\title {Think Python}
3433\author {Allen B. Downey}
3534\newcommand {\thetitle }{Think Python: How to Think Like a Computer Scientist}
36- \newcommand {\theversion }{2nd Edition, Version 2.2.16 }
35+ \newcommand {\theversion }{2nd Edition, Version 2.2.19 }
3736\newcommand {\thedate }{}
3837
3938% these styles get translated in CSS for the HTML version
@@ -720,9 +719,10 @@ \section*{Contributor List}
720719% ENDCONTRIB
721720
722721In addition, people who spotted typos or made corrections include
722+ Czeslaw Czapla,
723723Richard Fursa, Brian McGhie, Lokesh Kumar Makani, Matthew Shultz, Viet
724724Le, Victor Simeone, Lars O.D. Christensen, Swarup Sahoo, Alix Etienne,
725- Kuang He, Wei Huang, and Karen Barber.
725+ Kuang He, Wei Huang, Karen Barber, and Eric Ransom .
726726
727727
728728
@@ -3180,7 +3180,7 @@ \section{Interface design}
31803180
31813181{\tt n} is the number of line segments in our approximation of a circle,
31823182so {\tt length} is the length of each segment. Thus, {\tt polygon}
3183- draws a 50-sides polygon that approximates a circle with radius {\tt r}.
3183+ draws a 50-sided polygon that approximates a circle with radius {\tt r}.
31843184
31853185One limitation of this solution is that {\tt n} is a constant, which
31863186means that for very big circles, the line segments are too long, and
@@ -3207,7 +3207,7 @@ \section{Interface design}
32073207\begin {verbatim }
32083208def circle(t, r):
32093209 circumference = 2 * math.pi * r
3210- n = int(circumference / 3) + 1
3210+ n = int(circumference / 3) + 3
32113211 length = circumference / n
32123212 polygon(t, n, length)
32133213\end {verbatim }
@@ -3217,6 +3217,8 @@ \section{Interface design}
32173217enough that the circles look good, but big enough to be efficient,
32183218and acceptable for any size circle.
32193219
3220+ Adding 3 to {\tt n} guarantees that the polygon has at least 3 sides.
3221+
32203222
32213223\section {Refactoring }
32223224\label {refactoring }
@@ -8116,11 +8118,13 @@ \section{List arguments}
81168118It is important to distinguish between operations that
81178119modify lists and operations that create new lists. For
81188120example, the {\tt append} method modifies a list, but the
8119- {\tt +} operator creates a new list:
8121+ {\tt +} operator creates a new list.
81208122\index {append method}
81218123\index {method!append}
81228124\index {list!concatenation}
81238125\index {concatenation!list}
8126+
8127+ Here's an example using {\tt append}:
81248128%
81258129\begin {verbatim }
81268130>>> t1 = [1, 2]
@@ -8131,19 +8135,20 @@ \section{List arguments}
81318135None
81328136\end {verbatim }
81338137%
8134- {\tt append} modifies the list and returns {\tt None}.
8138+ The return value from {\tt append} is {\tt None}.
8139+
8140+ Here's an example using the {\tt +} operator:
81358141%
81368142\begin {verbatim }
81378143>>> t3 = t1 + [4]
81388144>>> t1
81398145[1, 2, 3]
81408146>>> t3
81418147[1, 2, 3, 4]
8142- >>> t1
81438148\end {verbatim }
81448149%
8145- The { \tt +} operator creates a new list and leaves the
8146- original list unchanged.
8150+ The result of the operator is a new list, and the original list is
8151+ unchanged.
81478152
81488153This difference is important when you write functions that
81498154are supposed to modify lists. For example, this function
@@ -16567,7 +16572,7 @@ \section{Order of growth}
1656716572problems asymptotic behavior is irrelevant.
1656816573
1656916574But if you keep those caveats in mind, algorithmic analysis is a
16570- useful tool. At least for large problems, the `` better'' algorithms
16575+ useful tool. At least for large problems, the `` better'' algorithm
1657116576is usually better, and sometimes it is {\em much} better. The
1657216577difference between two algorithms with the same order of growth is
1657316578usually a constant factor, but the difference between a good algorithm
0 commit comments