# Computer Science 222, Laboratory 6 – Graphics

Learning objectives:

• Use Python
methods for reading text files with numeric data.

• Use the
author-supplied graphics package.

Getting started:

programs graphics.py and graphics22.py. (We have found that on some machines graphics
works better, and on other machines graphics22 works better. We aren't sure why this is
so.) Try both graphics packages and use the one that works better.  For
each of the following, demonstrate your code to the instructor.

Part I. Files with Numeric Data.

1. Hourly Raise.

Each line of the file hourlyWages.txt contains information about employees for
some company in the form:

firstName lastName
hourlyWage numberOfHoursWorked

Each employee is getting a raise of \$1.65 per
hour.  Write a program hourlyWages.py that reads in each line of the file and
calculates each employee’s new pay for the week.  The program should then output each
employee’s first and last name and pay for that week to the file newHourlyWages.txt. Format the pay to two places after the
decimal.

Part II. Graphics.

2. Playing with Graphics.

Download the program Discussion3.py that is on pp. 159-60 of the text. Do programming
Exercise 1 on p. 160. Make sure that the center of the square is at the point
where the user clicks. Call your program squares.py.

3. Drawing a target.

Do Programming Exercise 2 on p. 160. Call your program
target.py.

4. Building a rectangle from its corners.

Do Programming Exercise 9 on p. 161.  Display
the numerical output in the graphics window – don't use

5. Drawing a circle from its center and radius.

Write a program called circle.py to draw a
circle. Make the window size 400 by 400. The first mouse click determines the
center of the circle. The second mouse click determines a point on its
circumference. Use the Euclidean distance formula to determine the length of

click to end the program, and be sure to close the window at the end.