Using the Miller/Ranum text with Python 2.x

Return to CS8 home page

Cover of textbook for CS8, Python Programming In Context, by Miller and Ranum


The textbook "Python Programming in Context" by Miller and Ranum is based on Python 3.0.

Miller and Ranum suggest in their "Note on Python 3.0" that the book can be used successfully with Python 2.x. in practice, some difficulties and challenges arise. This page describes these challenges, for two purposes:


In general, using Python 2.x for book designed for 3.x is difficult because:

If the differences were only in esoteric or advanced features, this might not be a problem. However, most of the difficulties actually arise in Chapter 1, with the first three significant encounters with programming.

Use of IDLE ( Section 1.5 intro, p. 9)

To be fair, this is not a Python 2.x vs. 3.x issue, but rather a separate issue with the Python install on CSIL: although Python 2.5.2 is installed on CSIL, it appears that the separate package "python-tools" is not installed.

Therefore, the example of bringing up the IDLE environment on page 9 will not yet work correctly on CSIL.

I've requested that this be installed for the 2.x Python version on CSIL—if/when this is done, this issue will disappear.

Integer vs. Floating Point Division (Section 1.5.1, p. 13)

In Python 3.x:

In Python 2.x:

From that point forward, things seem ok

As far as I can tell, I don't expect any further problems beyond these initial bumps in Chapter 1. So, if we can get past the problems listed above, it may be relatively smooth sailing with 2.x from that point forward.

There are, however, some serious caveats on this rosy picture:

One note about Turtle Graphics (Section 1.5.3, p. 24)

The book relies on Turtle graphics right from the beginning.

In fact all the programming examples in Chapter 1 use the cTurtle module. The authors use Turtle graphics to introduce fundamental ideas about abstraction and problem solving, as well as the syntax of function definitions. So, you really can't "just skip over" this topic.

You can't just run the examples out of the book unless you load the cTurtle module—this applies both Python 3.x and Python 2.x.

But, the version of cTurtle you need to load is different for 2.x vs. 3.x

In Python 2.x:

For Python 3.x:

See http://www.cs.ucsb.edu/~pconrad/cs8/topics/cTurtle/

Last update: P. Conrad, 05/24/2009

Valid XHTML 1.1 Valid CSS!