Computer Science I for majors by James Tam

Return to the course web page

CPSC 231: Mini-Assignment #5

Due Wednesday Nov 26, at 4 PM

New Concepts to be applied for the assignment

Description

Using the tkinter module write a Python program that will show randomly lit 'holiday lights'. Your program will create an animation window that contains three 'lights' are drawn using basic shapes: rectangles, ovals etc. and each shape is given a distinct fill color (see Figure 1). Lights will always be filled with some color (conversely none of the shapes be in an 'unfilled' state). In addition to drawing shapes, the program can create another window with a control button. Pressing the button will randomly change the color of the three lights (which is why you need to pick three distinct colors so your marker clearly make the determination that the colors are changing).  Although you don't have to use the starting sample program (see "Python programs" below) you will find it handy when trying to create the animation and control window.

Figure 1: Holiday lights

Example program executing

Submitting your work:

  1. Assignments (source code/'dot-py' file) must be electronically submitted according to [the assignment submission requirements] using [D2L]
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following [link].

Using pre-written Python libraries:

You are free to use any Python libraries/modules for this assignment. The tkinter module is of particular focus for this assignment.

Python programs:

There are two programs that were covered in tutorial that you find helpful for this assignment. You can find them in UNIX under: /home/231/tutorials/nov16_22 or directly via [link to tkinter examples]. The starting  program in UNIX under: /home/231/assignments/mini_assignment5 or via [shortcut link].

Marking key

Feature

Maximum marks

Draws 3 shapes 3
Each shape has distinctive fill color 3
Button events (maximum 6 marks) 6
  Button reacts in some way to presses (e.g., output message to console): 1 mark  
  Button press randomly colors the three shapes: full 6 marks  

TOTAL

12

Determining your assignment mark: Mapping of raw score to grade point

Raw score 12 11 10 9 8 7 6 5 4 3 2 1 0
Grade point 4 3.7 3.3 3.0 2.7 2.3 2.0 1.7 1.3 1.0 0.7 0.5 0