Mathematics for the Digital Age
and
Programming in Python
2nd Edition
Errata
Hardcover edition, 2-nd printing
================================
p. 182, 4th paragraph
eacn token's distance
should be:
each token's distance
p. 262, 2nd paragraph
Figures 14-2 and 14-3
should be:
Figures 15-2 and 15-3
pp. 284-285, Figures 16-3 and 16-4
A link is missing from Idaho to the region surrounding the map:
Idaho shares a border with Canada.
Answers and solutions, answer to Question 2 on p 172:
2^7 = 127
should be:
2^7 = 128
Hardcover edition, 1-st printing
================================
p. 4, Figure 1-2
One stray square in Range
p. 12, Example 2
Let p(n) be the highest power of 2 that divides n. That is, p(n) is the largest k
...
try every value of 2^k under n
should be:
Let p(n) be the largest k
...
try every value of 2^k less than or equal to n
p. 32, middle
return n*(n+1)/2
should be:
return n*(n+1)//2
p. 66, Figure 4.2:
The numbers and displacements should be 1, 1/2, 1/3, ...
where the length of a brick is 2. See
http://www.skylit.com/python/Figure4-2Correction.gif.
p. 112, #10, last paragraph:
raw_input
should be:
input
p. 113, #12 and solution:
isMersenne
should be:
isMersennePrime
p. 157, middle:
"but tuples have no methods at all"
That was true in Python 2. In Python 3 a tuple has methods count and index.
p. 163, paragraph before Example 4:
use print >>f, s
should be:
use print(s, file=f)
p. 164, Example 5:
print >>f, ' {0:4d} {1:5.2f} {2:7.2f}'.format(qty, price, amt)
should be:
print(' {0:4d} {1:5.2f} {2:7.2f}'.format(qty, price, amt), file=f)
p. 253, Question 4:
venn diagram
should be:
Venn diagram
Softcover edition
=================
p. 4, Figure 1-2
One stray square in Range
p. 12, Example 2
Let p(n) be the highest power of 2 that divides n. That is, p(n) is the largest k
...
try every value of 2^k under n
should be:
Let p(n) be the largest k
...
try every value of 2^k less than or equal to n
p. 32, middle
return n*(n+1)/2
should be:
return n*(n+1)//2
p. 44 last paragraph:
cordinates
should be:
coordinates
p. 46 Example 1:
return math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1)
should be:
return math.sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
p. 53 Example 4:
>>> msg = 'You can't change me!'
>>> msg
'You can't change me!'
>>> niceTry(msg)
>>> msg
'You can't change me!'
should be:
>>> msg = "You can't change me!"
>>> msg
"You can't change me!"
>>> niceTry(msg)
>>> msg
"You can't change me!"
p. 66, Figure 4.2:
The numbers and displacements should be 1, 1/2, 1/3, ...
where the length of a brick is 2. See
http://www.skylit.com/python/Figure4-2Correction.gif.
p. 157, middle:
"but tuples have no methods at all"
That was true in Python 2. In Python 3 a tuple has methods count and index.
p. 163, paragraph before Example 4:
use print >>f, s
should be:
use print(s, file=f)
p. 164, Example 5:
print >>f, ' {0:4d} {1:5.2f} {2:7.2f}'.format(qty, price, amt)
should be:
print(' {0:4d} {1:5.2f} {2:7.2f}'.format(qty, price, amt), file=f)
p. 253, Question 4:
venn diagram
should be:
Venn diagram