CS 111: Introduction to Computer Science

Playing with graphics

Today, you're going to play around with a graphics library developed by your textbook author, John Zelle. This library gives you tools for drawing simple pictures and responding to mouse clicks and keystrokes in your programs. The library is introduced in Chapter 4 of your textbook, and we'll use its features to introduce some more advanced Python features over the next few weeks.

To get started, download a copy of graphics.py into your working directory. (Either right-click on the link and select "Save Link As..." or just click on the link and do some copying and pasting.)

Each of the programs below contains instructions for you in its comments. Save a copy of each of the programs in your working directory, open each file in turn in a text editor, and follow the instructions, trying to answer the questions posed there. You do not need to hand in any of your answers. However, you should try hard to understand how each of the programs works, line by line.

You'll get the most out of these examples if you play around with them, experiment, just try changing the code in various ways to see what it does. Have some fun!

Done with all of that? Read the graphics.py documentation and experiment with features that aren't used in these exercises.