CSci 157 Homework #5
Due: February 27, 2025
This assignment is graded out of 50 points. For full credit:
- Turn your written submission in by class time on the due date
- Assignments are to be pledged and done individually
- See the Turning in Your Work section below
Reading. Zelle, Chapter 4
Written Problems (20 points).
- (5 points) What does the following expression evaluate to?
- (2 points) When range has 3 arguments, they are called start,
stop, and step. Describe what must be true of step
when start > stop.
- (3+5 points) Show how to modify each of the loops shown below so
that the statements in the loop body will execute 10 times.
The first loop must still use the range, but with the three arguments start, stop, and step. The second loop must still use a list. - (5 points) Download the program emoji.py,
which draws a small winking face in a window.
- Run the program to see what it does.
- Put a comment symbol
#
in front of the linewin.setCoords(...)
, this is called "commenting out" a line of code.
Run the program again and make note of what changes from the first run. - Research the
setCoords
method in the graphics package docs and write a paragraph explaining what the callwin.setCoords(...)
changed about the rest of the program. - Restore the line so that the program works as before.
Programming Problems (30 points)
Note: The coding standards (linked here) apply to your code and any code provided, such as programs from the textbook. In particular, include a file header (comment) at the top of each program you write, containing at least your name, homework number, and problem number if applicable.- (18 pts) Make Your Own Emoji - use the program emoji.py
as the basis for a new program that draws some other facial
expression or favorite emoji of another type.
- The new program should use Line and Polygon as well as the other shapes.
- Make your emoji just a bit larger than the one provided, so it can be easily seen, but not too large.
- In thinking how to work in Polygon:
where might a triangle or a star work? Does the
head have to be a circle? Use your imagination.
- (12 pts) Make a copy your emoji.py program file; call the
new one sevenEmojis.py
- Change the size of the window so it is much wider than it is high.
- Think of a way to replicate your emoji multiple times on a single row, starting no more than 5 pixels right of the left side of the window.
- Draw exactly 7 emojis. Hint: make the
x-coordinate of each
Point
used to draw the parts of the emoji a variable, modified by a for loop. - Make the width of the window so there is about the same amount
of space after the last emoji as there is to the left of the first
one.
Turning in Your Work
Written Problems. Options for turning in written exercises:
- complete the assignment on paper and turn in at the beginning of class on the due date
- complete the assignment in a text editor and post to the Assignments page on BrightSpace by the due date
- in either case, make sure your name is clearly visible
Programming Programs. Post your Python files to the Assignments page on BrightSpace either individually or combined into a single Zip file. Be sure your name is in a comment block at the top of each file.