Department of Mathematics, Computer Science, and
                Statistics
St.
                Lawrence University
Zonohedron
 

What is this object?

...

Links
Overview
Schedule
Grading Info
Class Notes

 

CS 140: Introduction to Computer Programming


HOMEWORK #4
due Friday, Sept 28 by 5:00pm

Guidelines for completing and submitting homework
Refer to the first two paragraphs on the Grading Info page for all the details.  Briefly, you may not collaborate with your classmates while writing homework programs.  However, you may certainly consult Spencer on Thursday evenings or Dr. V on Friday afternoons as you create your programs.  (Email your program to me first to check that I'm in the office.)  Other QRC mentors may also be able to help out, depending on their experience with Python.  Once you have completed your program, or made as much progress as possible, email your program as an attachment to svandervelde@stlawu.edu.

Assignment
To begin, create a new document in Komodo and include these comments at the top
# Your full name
# Homework #4, Sept 28, 2012
# Individuals providing assistance, if any

Then save your file using the format LastNameHW4.py.

Now write a program that performs the two tasks described below.  I will demo the first one in class so that you have a clear idea of what your program is supposed to do.  TIP: first copy lines of code from your line.py program to set up your graphics window and then close it again when the program is done.

  • To begin, open a 601 by 601 pygame window and select a background color of your choice.  Then write code that will create the line design pictured below.  Space your lines 10 pixels apart and use a time delay of .03 seconds between printing each line.  The goal is to create the illusion of a line spinning smoothly around the middle of the screen that draws the design.  The line should complete five full revolutions (i.e. trace out the entire design a total of five times), and your program should select a random color for the line each time through.



  • Now include a three second time delay, then clear the screen by setting the background to a new color.  Then draw a picture or animation of your choice.  This can be as simple or creative as you would like, as long as it includes at least one circle, at least one rectangle, and at least one for loop.
    FOR FUN:  I will create a gallery of the most interesting pictures and share them with the entire class when we gather again on Tuesday.