HW3: Basic Graphics Programming

25 points; due Wed 4/9 @ 9am.

Goals

The goal of this assignment is to use the features of Python to make some pictures, and to practice developing code with a text editor and the command line.

Setup and Requirements

This is the first full Python assignment that you will do with a text editor and the command line. It will be easiest to do this assignment on a machine in one of the CS labs.

You may work with a partner of your choice for this assignment. All work is to be done with both teammates working together at the computer. If you find that you absolutely can't schedule time to work together, split up for this assignment and turn in your own work.

If you work alone, put your name in a comment at the top of each file you submit. If you work in a pair, put both names at the top. Only one member of your team should submit your work; don't submit the same work from multiple accounts.

As always, ask lots of questions! Talk with classmates, the prefect, lab assistants, or me, or post on Piazza.

The graphics Module

In your home directory, create a directory called graphicsIntro to hold your work for this assignment. Start up a terminal and change to that directory.

Before you can make pictures, you need some helper code, which is in this file: graphics.py. Right-click that link, select Save Link As..., and save the file to the graphicsIntro directory that you just created.

You can open up graphics.py and look at it if you'd like. However, we won't really examine the inner workings of this code for a while; instead, we're just going to use it to build our own programs.

Now similarly download the file myArtwork.py to that same directory, and open it up in your text editor. Read through the code and see if you can figure out what it will do.

To run your program, run the following in the terminal:

python myArtwork.py

(Any time you get instructions to “run” a specific command in the terminal, what this means is that you should type it in on the command line, and then hit Enter.) What do you see? Try modifying the program to accomplish the following:

Take a few minutes to skim through the documentation for graphics.py to familiarize yourself with what tools are available. Then try picking out a few methods that look like they might be interesting, and try them out. Modify your program to use other methods from this documentation page.

Your Own Design

Write a Python program named myDrawing.py. Your program should create a GraphWin object and, using the methods in graphics.py, draw a picture. Spend a little bit of time experimenting with the different methods, and then figure out how to combine these methods to draw more complex shapes or pictures. Use some arithmetic operations as part of your program.

Some suggestions:

Be creative and have fun!

Submission

Creativity is highly valued in your work on this assignment!

Since this assignment is pretty open-ended, you may choose what you want to submit. You should submit at least two files: the modified myArtwork.py file, and the myDrawing.py file from the second part of the assignment. You may submit more than that if you'd like. There is no need to submit graphics.py or any files ending with .pyc.

In order to submit your work, you must zip all the files in your submission into a single .zip file. The following command creates a zip file called hw3.zip containing the files myArtwork.py and myDrawing.py:

zip hw3.zip myArtwork.py myDrawing.py

Use a similar command to create a zip file of your submission name hw3.zip, and turn it in on Moodle.

Again, only one member of a team needs to submit the work, but make sure that both team members' names are in comments in the program.

Assignment written by Amy Csizmar Dalal, Dave Musicant, and Jeff Ondich, with minor modification by Jadrian Miles.