Showing posts with label Chapter 4. Show all posts
Showing posts with label Chapter 4. Show all posts

Monday, November 2, 2009

Chapter 4 --Page 140-141 -- Listing 4.7

The values method returns a dict_values object, not a list. However, it can be turned into a list by using the list() function. Line 10 of listing 4.7 should be

countlist = list(countlist.values())

Then the max function is legal on countlist (as shown on line 11).

The text on page 140 should read

Recall that the values() method returns a dict_values object which can be turned into a list by applying the list function.

Tuesday, March 17, 2009

Chapter 4 -- Page 151 -- Problem 4.46

We felt that problem 4.46 deserved a bit more detail so we added it as programming exercise 4.2. Unfortunately, we forgot to delete 4.46.  To understand more about regression lines, refer to programming exercise 4.2.

Wednesday, February 4, 2009

Chapter 4 -- Page 128 -- Problem 4.6d

This problem asks you to implement a function that works like the list method find. Of course, there is no method find...it should be index. The problem should read...  Implement a function that works like the list method index.

Thursday, January 29, 2009

Chapter 4 -- Page 128 -- Problem 4.2g

In Python3.0, the sort method will not work across different data types. Performing sort on the list in this problem will cause an error.

>>> alist
[7, 9, 'a', 'cat', False]
>>> alist.sort()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: unorderable types: str() < int()