Friday, February 20, 2009

Chapter 2 -- Page 52 -- Listing 2.2

This code, as it evolved in Section 2.4.1, is not wrong but it does have an unfortunate use of identifier names.  The name sideS is meant to refer to the length of side S in the triangle shown. However, the parameter, sides, refers to the number of sides in the polygon being used for the approximation.  Since Python is case sensitive, these are two different names.  But they can easily be confused as seen in Line 12.  It would certainly have been better to name the parameter something like numSides.

No comments:

Post a Comment