Skip to content

Commit 3ebb7ef

Browse files
committed
Small fix in circle()
1 parent 571702a commit 3ebb7ef

File tree

2 files changed

+18
-13
lines changed

2 files changed

+18
-13
lines changed

book/book.tex

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
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)
@@ -33,7 +32,7 @@
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

722721
In addition, people who spotted typos or made corrections include
722+
Czeslaw Czapla,
723723
Richard Fursa, Brian McGhie, Lokesh Kumar Makani, Matthew Shultz, Viet
724724
Le, 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,
31823182
so {\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

31853185
One limitation of this solution is that {\tt n} is a constant, which
31863186
means that for very big circles, the line segments are too long, and
@@ -3207,7 +3207,7 @@ \section{Interface design}
32073207
\begin{verbatim}
32083208
def 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}
32173217
enough that the circles look good, but big enough to be efficient,
32183218
and 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}
81168118
It is important to distinguish between operations that
81178119
modify lists and operations that create new lists. For
81188120
example, 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}
81318135
None
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
81488153
This difference is important when you write functions that
81498154
are supposed to modify lists. For example, this function
@@ -16567,7 +16572,7 @@ \section{Order of growth}
1656716572
problems asymptotic behavior is irrelevant.
1656816573
1656916574
But 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
1657116576
is usually better, and sometimes it is {\em much} better. The
1657216577
difference between two algorithms with the same order of growth is
1657316578
usually a constant factor, but the difference between a good algorithm

code/polygon.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def arc(t, r, angle):
5757
angle: angle subtended by the arc, in degrees
5858
"""
5959
arc_length = 2 * math.pi * r * abs(angle) / 360
60-
n = int(arc_length / 4) + 1
60+
n = int(arc_length / 4) + 3
6161
step_length = arc_length / n
6262
step_angle = float(angle) / n
6363

0 commit comments

Comments
 (0)