Mathematics for the Digital Age
and
Programming in Python
Errata
p. 188 Example 4:
in you head
should be:
in your head
p. 278, Question 2:
OR
should be:
XOR
p. 278, Question 4:
for that year
should be:
for that year (assuming this is not a leap year)
p. 279, Question 13:
smallest k
should be:
smallest k > 1
p. 286-287, Questions 5-9:
Use consistently r^a. For example, in Question 5, a^(2^d)
should be r^(2^d)
===============================
Preliminary Edition
p. 10, Question 7:
The answer is 2, not 4.
p. 34, Question 1:
def first(s):
"Returns the first element in s"
return s[0]
should be:
def first(s):
return s[0]
p. 35, Question 8:
Write a Python function triangle(n) that has only one print statement and prints
*****
***
*
It should print the same three rows regardless of n.
should be:
Write a Python function triangle(n) that has only one print statement and prints
nnnnn
nnn
n
where n is a single-digit integer or a string of length 1.
For example, triangle(5) should print
55555
555
5
and
triangle('z') should print
zzzzz
zzz
z
[[ Hint: str(n) converts n into a string of its digits. ]]
p 40, Example 4:
>>> price = 60.00
should be:
# continued from Example 3
...
>>> price = 60.00
p. 41, 2nd paragraph:
>>> a = [1, 2] # assign a list [1, 2] to variable a
should be:
>>> a = [1, 2] # list [1, 2] is assigned to variable a
p. 44, 5th paragraph:
Python lets you use the value of a global variable within a function. But
you cannot set the value of a global variable within a function, because
then Python would think that you were introducing a new local variable
with the same name.
should be:
Python lets you use the value of a global variable within a function. But
if you try to set the value of a global variable within a function, without
an additional directive Python would think that you were introducing a
new local variable with the same name.
p. 60, Question 8:
Prove that in a geometric sequence
should be:
Prove that in a geometric sequence with positive terms
pp. 61-62, Example 1:
2^n should be replaced with 2^(n-1) and
2^(n+1) with 2^n in several places.
p. 109, Example 5:
while d < n/2:
should be:
while d <= n/2:
p. 134, Example 1:
In how many ways can a coach choose three players from a team of 7 players?
should be:
In how many ways can a coach choose three players, a point guard, a shooting guard, and a center,
from a team of 7 players?
p. 156, 3rd paragraph:
resultList = [2*x for x in lst]
should be:
resultLst = [2*x for x in lst]