Reading
- Think Python, Chapter 2
- Goldwasser & Letscher, Chapter 3, sections 3.1-3.2, pages 89-103
About this Problem Set
This problem set will get you acquainted with the mechanics of CS111 programming and with basic Python coding.
- In Task 1, you will modify a program that makes change for a given amount of money.
- In Task 2, you will create a graphics scene using the
cs1graphics
package.
All code for this assignment is available in the ps01_programs
folder in the cs111d
download directory on the cs
server.
This problem set will be graded using this grade sheet.
Working in Pairs
On Task 2 (and only Task 2), you are required to work with a partner as part of a two-person team. Your team will submit a single softcopy and hardcopy of your team-solution to Task 2 and the same grade will be given to both team members for Task 2.
All work by a team must be a true collaboration in which members actively work together on all parts of the Task. It is not acceptable for team members to split up the Task and work on parts independently. All programming should be done with both team members working at the same computer console. It is strongly recommended that both team members share the responsibility of "driving" (typing at the keyboard), swapping every so often. The only work that you may do alone is debugging code that you have written together and talking with the instructors and drop-in tutors.
There are many advantages to programming in pairs. People who program in pairs often claim to take less time than those who program alone. By continuously reviewing the code they find bugs sooner. Catching more bugs also leads to higher-quality code. When it comes to problem solving, two heads are better than one, and less time is spent exploring blind alleys. It can be a better learning experience, since team members both learn from and teach each other. And pair programmers often report that the experience is more enjoyable than programming alone. Many empirical studies have confirmed these and other benefits of pair programming. For example, see The Costs and Benefits of Pair Programming and other publications by Laurie Williams. It's also worth checking out the article All I Really Need to Know about Pair Programming I Learned in Kindergarten and the video Introduction to Pair Programming.
It's only fair to note that there are drawbacks to programming in pairs as well. Some pairs take longer to complete a program than they would individually. A mismatch in the skill level or working style of pair members can lead to friction between the individuals and disrupt the work. At Wellesley, the most common problem in pair programming is finding enough time in common to work together. You should not choose a partner to program with on Task 2 unless you can schedule at least a few hours to work together. Use this shared Google Doc to find a pair programming partner and record who your pair partner is.
Although you clearly can share Java code with your team partner on this assignment, other aspects of the course collaboration policy still hold. In particular, while you can talk with other individuals and teams about high-level problem-solving strategies, you cannot share any Java code with them.
How to turn in this Problem Set
You must submit both soft-copy (electronic) and hard-copy (printed) versions of your problem set.
Soft-copy submission
Save your modified makeChange.py
file in the MakeChange
folder. One and only one team member should save your newly created scene.py
file in their GraphicsScene
folder. This file should have both partners names at the top. Also, any Image file (GIF files tend to work best) that you use in your graphics scene must be included in the GraphicsScene
folder. Submit the entire ps01_programs
folder (renamed to yourname_ps01_programs) to your drop
folder on the cs
server using Fetch (for Macs) or WinSCP (for PCs).
Hard-copy submission
Print out your makeChange.py
file. One and only one partner should print out your scene.py
file with both partners names at the top.. Staple all pages together with a cover page, and submit this hardcopy package on the due date.
Task 1:Making Change
In this task, you will write a program that makes change for a specified amount of money. To get you started, we have provided you with a file, makeChange.py
, in the MakeChange
folder as part of the ps01_programs
folder from the download directory on the cs
server. The starter code prompts the user to enter an amount of cents and the program calculates and outputs how to make correct change for the specified amount using the fewest possible number of quarters and pennies. You should execute and study this starter code. Your goal is to modify makeChange.py
so that the program makes correct change for a specified amount of money (now dollars and/or cents) using the fewest possible number of $20 bills, $10 bills, $5 bills, $1 bills, quarters, dimes, nickels, and pennies.
To give you a sense (sense/cents... get it?) of how your program should behave, we have included a sample solution, makeChange_Sols.pyc
, that you can experiment with. To execute the sample solution, open Canopy and make sure that the current directory is set to the location of the makeChange_Sols.pyc
file in the MakeChange
folder in the ps01_programs
folder. In the command-line console, enter from makeChange_Sols import *
and then enter run()
each time you want to execute the sample solution code, as shown below:

Some important notes on this task:
- Your program need not handle cases when the user enters invalid input, e.g., a negative number, a word or other non-decimal number, a fractional amount of cents (0.15485).
- There are a number of built-in Python functions that you will need to use to complete this task. For example, the
raw_input
function prints a string to the console and waits for the user to enter a line. The line entered by the user is returned as a string. - To convert integers or floating point numbers (i.e., decimal numbers) to strings, you can use the built-in
str
function. To convert a string to an integer or floating point number, you can use the built-inint
orfloat
functions.
Task 2:Graphics Scene
For this task (and only this task), you are required to work with a partner as part of a two-person team. Your team will submit a single softcopy and hardcopy of your team-solution to the task and the same grade will be given to both team members for the task. Please see the top of this web page for details about pair programming. (Note: In extenuating circumstances, you may ask an instructor for an exception to the pair programming requirement.)
In the GraphicsScene
folder, we have included a copy of the cs1graphics
package. In this task, you are to create a new file, scene.py
, from scratch in the GraphicsScene
folder that creates your own novel scene on a Canvas
object. Since we have a limited number of shapes at our disposal, we encourage abstarct and creative artwork. Your scene.py
file must satisfy the following criteria:
- Your file must start with comments at the top, identifying the authors, problem set number, and title, e.g.,
# Grace Hopper and Ada Lovelace
# CS111 Problem Set 1
# Graphics Scene - Your file must appropriately
import
thecs1graphics
package. - Your canvas must have a descriptive title
- You must use at least one instance of each of the following classes:
Circle
,Ellipse
,Rectangle
,Polygon
,Path
, andText
- You must vary the border thickness and colors of some shapes
- You must vary the interior colors for some of your fillable objects, including at least one that has transparent color
- You must include an Image in your scene. Note that this requires that you include the image file in your
GraphicsScene
folder when you submit your assignment (GIF files tend to work best). It is OK if your image has a background that is not transparent. - You must position at least one object so that it is partially obscuring another object in your scene