Errata, First Printing
CHAPTER 1
p. xiii
| Printed: | ...we refer to "Python" after "programming in the title... |
| Fixed: | ...we refer to "Python" after "programming" in the title... |
p. 4, box at bottom
| Printed: | The lingua france in this book is Python 3. |
| Fixed: | The lingua franca in this book is Python 3. |
p. 16, line 9
| Printed: | ...variable whose associated a data-type value does not change during the execution... |
| Fixed: | ...variable whose associated data-type value does not change during the execution... |
p. 17, "Assignment Statements" paragraph
| Printed: | The left side of an assignment statement must be a single variable. |
| Fixed: | For now, the left side of an assignment statement must be a single variable; Section 3.3 elaborates. |
p. 24, second paragraph
| Printed: | ...often in conjunction with the str() function... |
| Fixed: | ...often in conjunction with the str() function... |
p. 28, Typical float expressions table
| Printed: | To be consistent with the associated text 6.02e23 should be
6.022e23, in two places. |
p. 33, caption of table at top
| Printed: | Truth-table proof that a and !(not a or not b) are identical. |
| Fixed: | Truth-table proof that a and not(not a or not b) are identical. |
p. 34, "Typical comparison expressions" insert
| Printed: | (b*b - 4.0*a*c) >= 0 |
| Fixed: | (b*b - 4.0*c) >= 0 |
p. 34, last full paragraph
| Printed: | ...and the comparison expression (year % 400) != 0) only if the year is divisible by 100. |
| Fixed: | ...and the comparison expression (year % 400) == 0) only if the year is divisible by 100. |
p. 38, Abbreviation alert
| Printed: | The function call sqrt(16.0) returns 4.0 |
| Fixed: | The function call math.sqrt(16.0) returns 4.0 |
p. 41
| Printed: | In a famous incident in 1985, a French rocket... |
| Fixed: | In a famous incident in 1996, a French rocket... |
p. 45, first line
| Printed: | ...so you can use them systems... |
| Fixed: | ...so you can use them in systems... |
p. 53, Exercise 1.2.22
| Printed: | w = 35.74 + 0.6215 T + (0.4275 T) - 35.75)v0.16 |
| Fixed: | w = 35.74 + 0.6215 t + (0.4275 t) - 35.75)v0.16 |
p. 53, Exercise 1.2.24
| Printed: | ... generated by the Math.random() method. |
| Fixed: | ... generated by the random.random() function. |
p. 57
| Printed: | if x >= 0:
stdout.write('not ')
stdout.writeln('negative')
|
| Fixed: | if x >= 0:
stdio.write('not ')
stdio.writeln('negative')
|
p. 57
| Printed: | if x >= 0:
stdout.write('not ')
stdout.writeln('negative')
|
| Fixed: | if x >= 0:
stdio.write('not ')
stdio.writeln('negative')
|
p. 58
| Printed: | stdio.writeln('Remainder = ' + num % den) |
| Fixed: | stdio.writeln('Remainder = ' + str(num % den)) |
p. 58, "Typical examples of using if statements" insert
| Printed: | discriminant = b*b - 4.0*a*c |
| Fixed: | discriminant = b*b - 4.0*c |
p. 60, Flowchart example (while statement)
| Printed: | stdio.writelnln(str(i) + 'th Hello') |
| Fixed: | stdio.writeln(str(i) + 'th Hello') |
p. 61, Anatomy of a while loop
| Printed: | stdio.writelnln(str(i) + 'th Hello') |
| Fixed: | stdio.writeln(str(i) + 'th Hello') |
p. 63, first paragraph
| Printed: | If i is 4 before the statement executed... |
| Fixed: | If i is 4 before the statement executes... |
p. 64, Description of powersoftwo.py
| Printed: | ...the first n powers of 2. |
| Fixed: | ...the first n+1 powers of 2. |
p. 64, Description of powersoftwo.py
| Printed: | ...the program write n + 1 lines. |
| Fixed: | ...the program writes n + 1 lines. |
p. 69, Flowchart for divisorpattern.py, in the leftmost box
| Printed: | stdio.writeln(' ') |
| Fixed: | stdio.writeln('* ') |
p. 71
| Printed: | if income < 0.0: |
| Fixed: | if income < 0: |
p. 71
| In the code template defining "else if" clauses, "block of statements" should be italicized. |
p. 75, Box describing variables
| Printed: | t: estimate of c |
| Fixed: | t: estimate of square root of c |
p. 77
| Printed: | % python binary.py 512 |
| Fixed: | % python binary.py 512 |
p. 81
| Printed: | ...each iteration of the outer for loop... |
| Fixed: | ...each iteration of the outer while loop... |
p. 82, first paragraph
| Printed: | ... the while loop will do its job and the invariant will continue to hold. |
| Fixed: | ... the inner while loop will do its job and the invariant will continue to hold. |
p. 83
| Printed: | x = 1.0 + 2.0*random.random()y = 1.0 + 2.0*random.random( |
| Fixed: | x = -1.0 + 2.0*random.random()y = -1.0 + 2.0*random.random() |
p. 83, last paragraph
| Printed: | First, suppose that such a loop calls stdout.writeln(). |
| Fixed: | First, suppose that such a loop calls stdio.writeln(). |
p. 84, first (partial) paragraph
| Printed: | ...on an infinite loop of stdout.writeln() calls... |
| Fixed: | ...on an infinite loop of stdio.writeln() calls... |
p. 84, first full paragraph
| Printed: | One way to locate such a bug is to insert calls of stdout.writeln() to produce a trace. |
| Fixed: | One way to locate such a bug is to insert calls of stdio.writeln() to produce a trace. |
p. 84, "An infinite loop (with output)" insert
| The output of the program is incorrect. It should not contain "1st Hello", "2nd Hello", or "3rd Hello", and should begin with "4th Hello". |
p. 90, Exercise 1.3.10
| Printed: | for n = 2, 4, 8, 16, 32, 64, ..., 2048 |
| Fixed: | for n = 2, 4, 8, 16, 32, 64, 128 |
p. 90, Exercise 1.3.11
| Printed: | n /= 10 |
| Fixed: | n //= 10 |
p. 91, Exercise 1.3.13
| Printed: | Your program should write nothing if n is negative" |
| Fixed: | Your program should write nothing if n is negative or zero" |
p. 92, Exercise 1.3.19
| Printed: | Modify binary.py... |
| Fixed: | Modify binary.py (Program 1.3.7)... |
p. 92, Exercise 1.3.20
| Printed: | v /= 2 |
| Fixed: | v //= 2 |
p. 92, Exercise 1.3.20
| Printed: | ...into a String s |
| Fixed: | ...into a string s |
p. 93, Exercise 1.3.21
| Printed: | Compose a version of gambler.py... |
| Fixed: | Compose a version of gambler.py (Program 1.3.8)... |
p. 93, Exercise 1.3.25
| Printed: | Modify factors.py... |
| Fixed: | Modify factors.py (Program 1.3.9)... |
p. 93, Exercise 1.3.26
| Printed: | ...using the termination condition instead of (i*i <= n) in factors.py... |
| Fixed: | ...using the termination condition instead of (factor*factor <= n) in factors.py... |
p. 94, Exercise 1.3.31
| Printed: | ... b to 2 * sqrt(1 - sqr(x) - sqr(y)) |
| Fixed: | ... b to 2 * y * sqrt(1 - sqr(x) - sqr(y)) |
p. 95, Exercise 1.3.33
| Printed: | The checksum digit d[i]... |
| Fixed: | The checksum digit d[1]... |
p. 96, Exercise 1.3.37 solution
| Printed: | To compute 3x, we nest this for loop within another for loop |
| Fixed: | To compute 3x, we nest this for loop within a while loop |
p. 97, Exercise 1.3.39
| Printed: | ...the direct method with nested for loops, the improvement with a single while loop, and the latter with the termination condition (term > 0). |
| Fixed: | ...the direct method with nested loops, the improvement with a single loop, and the latter with the loop continuation condition (term > 0). |
p. 101
| Printed: | y = [0.40, 0.10, 0.50] |
| Fixed: | y = [0.50, 0.10, 0.40] |
p. 101
The suits array is constant, and so really should be named SUITS (4 places). |
p. 101
| Printed: | ...y[2] refers to .50... |
| Fixed: | ...y[2] refers to .40... |
p. 102, first code fragment
| Printed: | for i in range(n) |
| Fixed: | for i in range(n): |
p. 102, second code fragment
| Printed: | for i in range(n) |
| Fixed: | for i in range(n): |
p. 103, Memory representation paragraph
| Printed: | Accessing a reference to element i of an array... |
| Fixed: | Accessing element i of an array... |
p. 103, Memory representation paragraph
| Printed: | ...Python generates code that adds the index i to the memory address of the first element of the array. |
| Fixed: | ...Python generates code that adds the index i to the memory address that references the address of the first element of the array. |
p. 104
| Printed: | In the "Informal trace for reversing an array," in the row for the 3rd iteration of i, the number between 5 and 4 is 3. |
| Fixed: | That number should be 1. |
p. 105, second paragraph
| Printed: | in an array in a[] |
| Fixed: | in an array a[] |
p. 105, first code fragment
| Printed: | for i in range(len(a)) |
| Fixed: | for i in range(len(a)): |
p. 110, table
| Printed: | assign v to each of the elements in a[] |
| Fixed: | assign to v each of the elements in a[] |
p. 111, last paragraph
| Printed: | ...the values a[i] and a[j] are found... |
| Fixed: | ...the values deck[i] and deck[j] are found... |
p. 112, "Sampling without replacement paragraph
| Printed: | ...each element in set... |
| Fixed: | ...each element in the set... |
p. 113, sample.py code listing
| Printed: | # Create a random sample of size m in perm[0..m). |
| Fixed: | # Create a random sample of size m in perm[0:m]. |
p. 116, table
| The columns entitled "count" and "collectedCount" should be switched. |
p. 116, table
| The column entitled "val" instead should be entitled "value". |
p. 118
| Printed: | The program uses an array isPrime[] of n booleans... |
| Fixed: | The program uses an array isPrime[] of n+1 booleans... |
p. 120
| Printed: | When the nested for loop ends... |
| Fixed: | When the nested for loops end... |
p. 122
| Printed: | ...the array [[18, 19, 20], [21 22, 23]]... |
| Fixed: | ..the array [[18, 19, 20], [21, 22, 23]]... |
p. 123, Typical spreadsheet calculations
| Printed: | a[i][n] = total / m |
| Fixed: | a[i][n] = total / n |
p. 123, Typical spreadsheet calculations
| Printed: | a[m][j] = total / n |
| Fixed: | a[m][j] = total / m |
p. 123
| Printed: | ...divide by n. The column-by-column... |
| Fixed: | ...divide by m. The column-by-column... |
p. 124
| Printed: | The definition extends to matrices that may not be square (see Exercise 1.4.17). |
| Fixed: | The definition extends to matrices that may not be square (see Exercise 1.4.16). |
p. 125
| Printed: | For example, the row-average computation for such a spreadsheet is equivalent to a matrix-vector multiplication where the row vector has n elements all equal to 1.0 / n. Similarly the column-average computation in such a spreadsheet is equivalent to a vector-matrix multiplication where the column vector has m elements all equal to 1.0 / m. |
| Fixed: | For example, the row-average computation for such a spreadsheet is equivalent to a matrix-vector multiplication where the column vector has n elements all equal to 1.0 / n. Similarly the column-average computation in such a spreadsheet is equivalent to a vector-matrix multiplication where the row vector has m elements all equal to 1.0 / m. |
p. 126
| Printed: | ...whose dimensions are give by the variable m and n. |
| Fixed: | ...whose dimensions are give by the variables m and n. |
p. 126
| Printed: | ...provide the basis for a models of the physical world. |
| Fixed: | ...provide the basis for models of the physical world. |
p. 130
| Printed: | ...including resizing arrays, linked lists, and binary search trees, and hash tables. |
| Fixed: | ...including resizing arrays, linked lists, binary search trees, and hash tables. |
p. 134, Exercise 1.4.14
| Printed: | ...have no common factors... |
| Fixed: | ...have no common factors other than 1. |
p. 144, "Anatomy of a formatted print statement" insert
| Printed: | comversion specification |
| Fixed: | conversion specification |
p. 150, "Description of Program 1.5.2
| Printed: | ...with fewer than 20 questions |
| Fixed: | ...with at most 20 questions |
p. 152, Program 1.5.3
| Printed: | The commands shown below after the first one use redirection and piping (discussed in the next subsection) to provide 100,000 numbers to average.py. |
| Fixed: | The commands shown below after the first one use redirection and piping (discussed in the next subsection) to provide 1000 numbers to average.py. |
p. 154
| Printed: | ...or it might run average.py until it needs some output, and then run randomseq.py until it produces the needed output. |
| Fixed: | ...or it might run average.py until it needs some input, and then run randomseq.py until it produces the needed input. |
p. 167
| In the lower right image the white text should be centered in the black square. |
p. 169
| Printed: | ...most of the ball's pixels alternate between black and white |
| Fixed: | ...most of the ball's pixels alternate between black and gray |
p. 172
| Printed: | a = stdarray.create1D(n+1) |
| Fixed: | a = stdarray.create1D(n+1, 0.0) |
p. 177, First answer
| Printed: | You want to use the format 7.2f to specify seven characters in total -- four before the decimal point, the decimal point itself, and two digits after the decimal point. |
| Fixed: | You want to use the format 5.2f to specify five characters in total -- two before the decimal point, the decimal point itself, and two digits after the decimal point. |
p. 179, Exercise 1.5.7
| Printed: | read from standard input N-1 distinct integers |
| Fixed: | read from standard input n-1 distinct integers |
p. 179, Exercise 1.5.8
| Printed: | The harmonic mean is (1/x1 + 1/x2 + ... + 1/xn) / (1/n). |
| Fixed: | The harmonic mean is n / (1/x1 + 1/x2 + ... + 1/xn). |
p. 180, Exercise 1.5.10
| Printed: | python randomintseq.py 200 100 |
| Fixed: | python randomintseq.py 100 200 |
p. 183, Exercise 1.5.24
| Printed: | of approximate size r times a.length. |
| Fixed: | of approximate size r times len(a). |
p. 191
| The tiny.txt file used in Section 1.6 conflicts with the tiny.txt file used in Section 4.2. Change the name of tiny.txt on this page and throughout Section 1.6 to small.txt. |
p. 192
| Printed: | for j in range(0, n) |
| Fixed: | for j in range(0, n): |
p. 201
| Because of an error in the text file that represents the graph, the numbers on the right side of the page and the histogram at the bottom of the page do not correspond exactly to the graph. |
CHAPTER 2
p. 211
| Printed: | The diagram on the next page illustrates the flow of conrtol for the command python harmonicf.py 1 2 3 |
| Fixed: | The diagram on the next page illustrates the flow of conrtol for the command python harmonicf.py 1 2 4 |
p. 214, line 8
| Printed: | shown at right |
| Fixed: | shown at left |
p. 211
| Printed: | def hypot(a, b) |
| Fixed: | def hypot(a, b): |
p. 218, second paragraph
| Printed: | H2,2 = 49/36 |
| Fixed: | H3,2 = 49/36 |
p. 220
| Printed: | def hypot(a, b) |
| Fixed: | def hypot(a, b): |
p. 220
| Printed: | 0.5*0.982 + 0.5*0.693 |
| Fixed: | 0.5*0.982 + 0.5*(-0.693) |
p. 229
| Printed: | a = stdarray.create1D(n) |
| Fixed: | a = stdarray.create1D(n , 0.0) |
p. 234, inset describing Program 2.1.4
| Printed: | h[] | combined harmonics |
| Fixed: | harmonics[] | combined harmonics |
p. 235
| Printed: | ...as illustrated in the figure below... |
| Fixed: | ...as illustrated in the figure to the right... |
p. 235, figure
| Printed: | stdaudio.playArray(a) |
| Fixed: | stdaudio.playSamples(a) |
p. 243, Exercise 2.1.22
| Printed: | (see Exercise 1.4.35) |
| Fixed: | (see Exercise 1.4.36) |
p. 262
| Printed: | discrete[5, 3, 1, 1] |
| Fixed: | discrete[.5, .3, .1, .1] |
p. 267, in the table
| Printed: | x = 0.16y |
| Fixed: | y = 0.16y |
p. 274, in the "Plotting a sound wave" inset
| Printed: | See Program 2.4.7 |
| Fixed: | See Program 2.1.4 |
p. 296, in the "Function call trace for gcd()" insert
| Printed: | gcd(216, 24) |
| Fixed: | gcd(216, 192) |
p. 303, the 12th line of the output of "python beckett 4"
| Printed: | enter 3 |
| Fixed: | exit 3 |
p. 314, the second line of the ex235() function
| Printed: | z = ex233(n-3) + str(n) + ex235(n-2) + str(n) |
| Fixed: | z = ex235(n-3) + str(n) + ex235(n-2) + str(n) |
p. 315, Exercise 2.3.8
| Printed: | return mystery(a+a, b/2) |
| Fixed: | return mystery(a+a, b//2) |
p. 315, Exercise 2.3.8
| Printed: | return mystery(a+a, b/2) + a |
| Fixed: | return mystery(a+a, b//2) + a |
p. 333, in the text describing Program 2.4.5
| Printed: | ...no different from coin flipping (see Program 2.2.6). |
| Fixed: | ...no different from coin flipping (see Program 2.2.7). |
p. 339
| Printed: | plot the two halves of the curve, from (x0,y0) to (xm,ym), and from (xm, ym) to (x1,y1). |
| Fixed: | plot the two halves of the curve, from (x0,y0) to (xm,f(xm)), and from (xm, f(xm)) to (x1,y1). |
p. 345, Exercise 2.4.1
| Printed: | ...with the element in row n and column j set to True if... |
| Fixed: | ...with the element in row i and column j set to True if... |
p. 348, Exercise 2.4.21
| Printed: | ...but with eight recursive calls instead of four. |
| Fixed: | ...but with six recursive calls instead of four. |
p. 349, Exercise 2.4.22
| Printed: | A live cell with exactly one live neighbor becomes dead. |
| Fixed: | A live cell with fewer than two live neighbors becomes dead. |
CHAPTER 3
p. 362
| Printed: | so this potential is 8.99 × 109 × 0.51 / 0.34 = 1.35 × 1010 |
| Fixed: | so this potential is 8.99 × 109 × 21.3 / 0.34 = 5.63 × 1011 |
p. 363, in the box showing executions of chargeclient.py
| Printed: | is 2.56+12 |
| Fixed: | is 2.56e+12 |
p. 375, first paragraph, sixth line
| Printed: | ...so the pixel n column 4 and column 6 |
| Fixed: | ...so the pixel n column 4 and row 6 |
p. 378
| Because of the error in charge.py on page 409, the potential.py image contains three pixels that are white but should be black. |
p. 385, Description of end variable
| Printed: | </span> after |
| Fixed: | </span> after |
p. 388
| Printed: | (the one at (.51, .63) with potential 21.3) |
| Fixed: | (the one at (.51, .63) with charge value 21.3) |
p. 391, in the 4th answer
| Printed: | For example, 'python'.upper() returns 'Python' and... |
| Fixed: | For example, 'python'.upper() returns 'PYTHON' and... |
p. 393, Exercise 3.1.1
| Printed: | ...creates four Charge objects that are each distance w... |
| Fixed: | ...creates four Charge objects (each with charge value 1.0) that are each distance w... |
p. 404, "Anatomy of a constructor" diagram
| Printed: | self._rx = x0 self._rx = x0 |
| Fixed: | self._rx = x0 self._ry = y0 |
p. 406, first paragraph
| Printed: | ...the value of the self parameter variable of the __potentialAt__() method is set to c. |
| Fixed: | ...the value of the self parameter variable of the potentialAt() method is set to c. |
p. 409
| Printed: | and a test client main() (see also Program 3.1.1). |
| Fixed: | and a test client main() (see also Program 3.1.2). |
p. 409
| Printed: | r = math.sqrt(dx*dx + dy*dy)
if r == 0.0: return float('inf') |
| Fixed: | r = math.sqrt(dx*dx + dy*dy)
if r == 0.0:
if self._q >= 0.0:
return float('inf')
else:
return float('-inf') |
p. 411
| automatic string conversion; Python calls str(c) | automatic string conversion; Python calls c.__str__() |
p. 413
In stopwatch.py the import math statement is unnecessary. |
p. 415
| Printed: | heads = bernoulli.binomial(n, p) |
| Fixed: | heads = stdrandom.binomial(n, p) |
p. 416, at the beginning of the 3rd paragraph
| Printed: | For example, to graw a triangle we create a turtle at (0, 0.5) facing... |
| Fixed: | For example, to graw a triangle we create a turtle at (0.5, 0) facing... |
p. 428, Table at bottom
| The entry at row z2 and column 2+0i should be 38, not 36. |
p. 438, Second bullet point
| Printed: | A constant variable name starts with an uppercase letter. |
| Fixed: | A constant variable name consists of uppercase letters. |
p. 439, First question
| Printed: | You said that mandelbrot.py creates hundreds of millions of complex objects. |
| Fixed: | The mandelbrot.py program creates a huge number of complex objects. |
p. 442, Exercise 3.2.7
| Printed: | Python provides a data type Fraction, defined in the standard module fraction.py, that implements rational numbers. |
| Fixed: | Python provides a data type Fraction, defined in the standard module fractions.py, that implements rational numbers. |
p. 443, Exercise 3.2.8
| Printed: | a.contains(b): does interval a contain interval b? |
| Fixed: | a.contains(b): does interval a contain b? |
p. 445, Exercise 3.2.21
| Printed: | charge.Charge(...) |
| Fixed: | Charge(...) |
p. 456
| Printed: | def __abs__(self): return self.r |
| Fixed: | def __abs__(self): return self._r |
p. 463
| Printed: | v = new Vector(a) |
| Fixed: | v = Vector(a) |
p. 471, third line
| Printed: | ...b would get assigned the integer 33... |
| Fixed: | ...b would get assigned the float 17.46424919657298... |
p. 482
The data in the "Profiling genomic data" table are incorrect. These are the correct data:
2-gram hash count unit count unit
AA 0 0 0 2 0.139
AC 1 0 0 1 0.070
AG 2 3 0.397 2 0.139
AT 3 4 0.530 1 0.070
CA 4 2 0.265 2 0.139
CC 5 0 0 2 0.139
CG 6 1 0.132 6 0.417
CT 7 0 0 4 0.278
GA 8 1 0.132 2 0.139
GC 9 4 0.530 6 0.417
GG 10 0 0 2 0.139
GT 11 0 0 4 0.278
TA 12 3 0.397 0 0
TC 13 0 0 5 0.348
TG 14 1 0.132 4 0.278
TT 15 0 0 6 0.417
|
p. 483
| Printed: | for i in range(len(text) - k): |
| Fixed: | for i in range(len(text) - k + 1): |
p. 485
| In the "more documents.txt" insert "picture.py" should be "vector.py". |
p. 485
The output of the comparedocuments.py program is incorrect. Specifically, the numbers in the "vect" row and the "vect" column are incorrect. This is the correct output:
$ python comparedocuments.py 5 10000 < documents.txt
cons toms huck prej vect djia amaz actg
cons 1.00 0.69 0.63 0.67 0.09 0.15 0.19 0.12
toms 0.69 1.00 0.93 0.89 0.07 0.18 0.19 0.14
huck 0.63 0.93 1.00 0.83 0.05 0.16 0.16 0.13
prej 0.67 0.89 0.83 1.00 0.06 0.20 0.20 0.14
vect 0.09 0.07 0.05 0.06 1.00 0.02 0.19 0.02
djia 0.15 0.18 0.16 0.20 0.02 1.00 0.11 0.07
amaz 0.19 0.19 0.16 0.20 0.19 0.11 1.00 0.06
actg 0.12 0.14 0.13 0.14 0.02 0.07 0.06 1.00
|
p. 490, second question
| Printed: | Is there is any situation... |
| Fixed: | Is there any situation... |
p. 499
In the "force from one body to another" illustration the
intention is to show a.forceFrom(b). However the arrows
marked with a.forceFrom(b), delta.direction(),
and delta are in the opposite direction. |
CHAPTER 4
p. 513, insert
| Printed: | python threesum.py < 1Kints.txt python threesum.py < 2Kints.txt |
| Fixed: | python threesum.py < 1kints.txt python threesum.py < 2kints.txt |
p. 530
| Printed: | a .insert(0, 'slow')
|
| Fixed: | a.insert(0, 'slow')
|
p. 535
| Printed: | That is, the code fragment takes quadratic time as a function of the string length n (see Exercise 4.1.13). |
| Fixed: | That is, the code fragment takes quadratic time as a function of the string length n (see Exercise 4.1.15). |
p. 538, Exercise 4.1.14
| Printed: | Each of the four Python functions below... |
| Fixed: | Each of the five Python functions below... |
p. 540, Table
| Printed: | n-by-n array of floats |
| Fixed: | m-by-n array of floats |
p. 544, Solution to Exercise 4.1.5
| Printed: | For n > 2, count all the triples that do not include n |
| Fixed: | For n > 2, count all the triples that do not include n-1 |
p. 550, Exercise 4.1.16
| Printed: | r = stdrandom.uniform(0, n) |
| Fixed: | r = stdrandom.uniformInt(0, n) |
p. 552, Exercise 4.1.31
| Printed: |
def no2slash(name):
for x in range(len(name)):
if x > 0:
if (name[x-1] == '/') and (name[x] == '/'):
for y in range(x+1, len(name)):
name[y-1] = name[y]
else:
x += 1
|
| Fixed: |
def no2slash(name):
nameList = list(name)
x = 1
while x < len(nameList):
if (nameList[x-1] == '/') and (nameList[x] == '/'):
for y in range(x+1, len(nameList)):
nameList[y-1] = nameList[y]
nameList = nameList[:-1]
else:
x += 1
return ''.join(nameList) |
p. 553, Exercise 4.1.32
| Printed: | 99 91 92 93 94 |
| Fixed: | 90 91 92 93 94 |
p. 557, "Finding a hidden number with binary search insert
| In the insert entitled "Finding a hidden number with binary search" the blue lines in interval 64-80 and interval 72-80 are identical in the graph. The line for 72-80 should be half of the size of the line for 64-80. |
p. 560, "Binary representation" paragraph
| Printed: | greater than or equal to than 64 |
| Fixed: | greater than or equal to 64 |
p. 563, Final figure
| Printed: | equal to 64 + 8 + 4 + 2 + 1 |
| Fixed: | equal to 64 + 8 + 4 + 1 |
p. 565, Program 4.2.3
| Printed: | if a[mid] > key: |
| Fixed: | if key < a[mid]: |
p. 577, first full paragraph
| Printed: | The Python system sort uses a version of mergesort:. |
| Fixed: | The Python system sort uses a version of mergesort. |
p. 587, Exercise 4.2.22
| Printed: | ...the pair of integers that are closest in value. |
| Fixed: | ...the pair of floats that are closest in value. |
p. 587, Exercise 4.2.23
| Printed: | ...the pair of integers that are furthest apart in value. |
| Fixed: | ...the pair of floats that are furthest apart in value. |
p. 596
| Printed: | Node oldFirst = first |
| Fixed: | oldFirst = first |
p. 598, Description of Program 4.3.2
| Printed: | We defer the __len__() method to Exercise 4.3.4. |
| Fixed: | We defer the __len__() method to Exercise 4.3.6. |
p. 633, Exercise 4.3.46
| Printed: | - or 3 3 6 None None None not to not None None that 4 3 7 None None None not to not that None |
| Fixed: | - or 3 3 6 None None None not to be None None that 4 3 7 None None None not to be that None |
p. 633, Exercise 4.3.46
| Printed: | - or 3 3 6 None None None not to not None None that 4 3 7 None None None not to not that None |
| Fixed: | - or 3 3 6 None None None not to be None None that 4 3 7 None None None not to be that None |
p. 628, Exercise 4.3.33
| Printed: | (at positions numbered from 0 to n) |
| Fixed: | (at positions numbered from 0 to n-1) |
p. 664
| Printed: | import stdio |
| Fixed: | |
p. 664
| Printed: | stdio.writef('%4d %s\n', word, frequency) |
| Fixed: | stdio.writef('%s %4d\n', word, frequency) |
p. 671, Exercise 4.4.17
| Printed: | ... 24 30 30 38 ... |
| Fixed: | ... 24 30 31 38 ... |
p. 702, figure
| Printed: | _prev[w] |
| Fixed: | _edgeTo[w] |
p. 702, figure
| Printed: | ORF |
| Fixed: | ORD |