Building Your Own Modules 293
(between 3 and 6), the size of the spiral (between 25 and 75), and
the x- and y-coordinates to draw the spiral on the screen, between
(–300, –300) and (300, 300). (Remember that the turtle’s origin,
(0, 0), is at the center of the drawing screen.) Finally, each pass
through the loop calls the colorspiral.cspiral() function from our
module, drawing a colorful spiral with the randomly generated
attributes from the loop.
Although this program is only eight lines long, it produces
stunning graphics like Figure C-2.
Figure C-2: The colorspiral module allows SuperSpiral.py to produce a
lovely multispiral collage with only eight lines of code.
The ability to create reusable modules means that you can
spend more time solving new problems and less time recoding
previous solutions. Whenever you build a useful function or set
of functions that you want to use over and over, you can create a
module to use for yourself or share with fellow coders.