Problem Set 1 - Due Mon, Feb 6 at 23:59
Reading
- The CS111 Problem Set Guide gives an overview of psets, including a detailed description of individual and partner tasks
- Lecture 01 slides and notebook
- Lab 01
- Goldwasser & Letscher, Chapter 3, sections 3.1-3.2, pages 89-103
About this Problem Set
This problem set will give you practice with basic Python interactive programs as well as creating graphic scenes with the cs1graphics
library.
- In Task 0, you will familiarize yourself with the course google group, cs111-spring17.
- In Task 1, you will write a time profiler program that calculates and visualizes the time spent by a person per week on various activities.
- In Task 2 (Partner task), you will create a graphics scene using the
cs1graphics
package. - Use this shared Google Doc to find and record your pair programming partner. Please DO NOT use the cs111-spring17 group to find partners. Remember, you can talk with other individuals and teams about high-level problem-solving strategies, but you cannot share any code with them.
- Read the PS01 FAQ -- it covers the most common issues students encounter when working on PS01.
- The CS111 Problem Set Guide gives an overview of psets, including a detailed description of individual and partner tasks.
- In previous semesters, cs111 students spent an average of 3.54 hours on Task 1 (min = 1 hour, max = 9 hours) and 3.48 hours on Task 2 (min = 1 hour, max = 9 hours).
All code for this assignment is available in the ps01
folder in the cs111/download
directory within your cs
server account, which you learned how to access in Lab 1.
Guidelines for checking the correctness and quality of your solution are here.
Task 0: Ask or answer a question on cs111-spring17
On a typical problem set, we expect that you will have many questions.
You can seek answers to these questions from instructors during office hours; from tutors during drop-in hours; from SI leaders during their sessions; and from fellow classmates.
Another import way to ask questions is to post them on the cs111-spring17 Google group. This forum is monitored by the CS111 staff and your classmates, one of whom will try to answer your question in a timely fashion. To get you in the habit of posting to and reading this group, we require that every student posts at least one question or one answer on the cs111-spring17 group in the first couple weeks of the semester.
When do I post my question or my answer?
- if your last name starts with A-L, post during the week 01/30 - 02/06 [before 11:59pm on 02/06]
- if your last name starts with M-Z, you will post as part of the next pset (PS02)
Tips on posting to the course google group (cs111-spring17)
- Questions can involve anything related to the course: this assignment, material from lecture or lab, Canopy setup, etc.
- Do not post a question that has already been asked
- Do not post python code (if you do, we will delete your post)
- Do not use cs111-spring17 to find pset partners (use the pset partner google doc to facilitate partnering)
- Note that you can post to this group directly via email using the email address cs111-spring17@wellesley.edu.
Tips on email inbox management
With more than 80 students in the cs111-spring17 group, your inbox will quickly fill with messages.
- We strongly recommend that you learn how to organize your Gmail using labels, filters, and multiple inboxes to deal with the volume of email.
- This is important so that you don't miss emails from the instructors or tutors, which might contain urgent information about the course.
- Here are two short YouTube videos to help you, of course, there are many more of this flavor available online: Video 1: Setting up labels. Video 2: Multiple Inboxes.
If you have difficulties talk to an instructor or tutor.
Task 1: Time Profiler
This is an individual problem which you must complete on your own, and may ask for help from the CS111 staff.
Armed with Python knowledge from your first CS111 lectures and lab, you've decided to form a software startup that provides your fellow students with useful programs.
Since time is important to all Wellesley students, you've decided your first program should be a time profiler that helps students visualize how they spend their time during a typical week. The program will ask the user to enter a few pieces of information, and then will display a textual representation of the hours they spend in four activities during the week:
- Classwork: This includes time in class plus homework time. You may assume in general that two hours of homework time are required for every hour in class.
- Activities Outside of Class: This includes time spent in organized athletics, music activities, and clubs, as well as any jobs. Your program will ask the user to name this category.
- Sleep: This is the amount of time you spend sleeping each week.
- Free Time: For simplicity, this category encompasses all activities not covered by the other three activities above.
Each time you run your program (by pressing the green triangle in Canopy) it should prompt the user to enter information about these activities and display a time profile. Below are two example executions of the time profiling program that show how your program should behave. In each run, text in black is displayed by the program, while text in magenta is entered by the user.
Sample Execution #1
What is your name? Valentina How many classes are you taking this semester? 5 What is the average time in class per week this semester? 2.5 What shall we call the 'everything outside of class' category? fun How many hours per week do you spend on 'fun' activities? 15 How many hours per day do you sleep on average? 8 Weekly time profile for Valentina: 37.5 class hours: CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 15.0 fun hours: XXXXXXXXXXXXXXX 56.0 sleep hours: SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 59.5 free hours: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Sample Execution #2
What is your name? Emma How many classes are you taking this semester? 4 What is the average time in class per week this semester? 3.67 What shall we call the 'everything outside of class' category? extracurricular How many hours per week do you spend on 'extracurricular' activities? 22.5 How many hours per day do you sleep on average? 6.75 Weekly time profile for Emma: 44.04 class hours: CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 22.5 extracurricular hours: XXXXXXXXXXXXXXXXXXXXXXX 47.25 sleep hours: SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 54.21 free hours: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Sample Execution #3
What is your name? Sofia How many classes are you taking this semester? 4 What is the average time in class per week this semester? 3.2 What shall we call the 'everything outside of class' category? chill How many hours per week do you spend on 'chill' activities? 24 How many hours per day do you sleep on average? 6.55 Weekly time profile for Sofia: 38.4 class hours: CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC 24.0 chill hours: XXXXXXXXXXXXXXXXXXXXXXXX 45.85 sleep hours: SSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSSS 59.75 free hours: FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
Note that each row of the profile has a number of characters that is the rounded version of the number of hours displayed on the row. So in Sofia's profile, there are 38 C
s, 24 X
s, 46 S
s and 60 F
s. [NOTE: Thanks to Gloria, this was corrected on 01/30/17 9:48pm to 59.75 free hours (from a previously erroneous 53.1 free hours)]. You should use X
s to indicate the number of 'outside of class' hours. Also note that each number of hours has at least one digit after a decimal point, and at most two.
Note also that your program should ask the user for the name of the category used to describe 'activities outside of class' and then use that name in the remainder of the program. In the first example above, Valentina chose to use the name 'fun', Sofia chose to use the name 'chill' and Emma chose to use the label 'extracurricular'. The user of the program gets to decide which name to use to describe that category, and your program incorporates that name into the profile.
In your account on the cs
server is the CS111 download folder cs111/download
. This folder contains a subfolder name ps01
. Begin by copying this ps01
folder to your computer. This folder contains an empty subfolder named TimeProfiler
.
In this task, you will write a time profiling Python program timeProfiler.py
from scratch in Canopy that has the behavior indicated by the sample executions above. You should save this file to the TimeProfiler
subfolder of ps01
.
Your goal is to create a timeProfiler.py
program that behaves exactly as indicated by the sample executions above, and works reasonably on other sample inputs.
Incremental Development
Any major programming task like this should be broken down into smaller subtasks.
For example, start by writing code to solve the subtask of prompting the user for their name and displaying the header "Weekly time profile for (name):"
Sample Execution for Subtask 1
What is your name? Sofia
Weekly time profile for Sofia:
Second, add a prompt for the number of sleep hours and add a corresponding line to the output display.
Sample Execution for Subtask 2
What is your name? Sofia How many hours per day do you sleep on average? 6.55 Weekly time profile for Sofia: 45.85 sleep hours
Third, add a prompt for the name of the 'outside of class activities' category.
Sample Execution for Subtask 3
What is your name? Sofia What shall we call the 'everything outside of class' category? chill How many hours per day do you sleep on average? 6.55 Weekly time profile for Sofia: 45.85 sleep hours
Fourth, add a prompt for the number of -- in this particular case, chill -- hours, and add a corresponding line to the output display.
Sample Execution for Subtask 3
What is your name? Sofia What shall we call the 'everything outside of class' category? chill How many hours per week do you spend on 'chill' activities? 24 How many hours per day do you sleep on average? 6.55 Weekly time profile for Sofia: 24.0 chill hours 45.85 sleep hours
Continue in this way until you have prompts for all inputs and are able to produce the following (of course, your output will vary depending on what the user enters for the 'outside of class' category). Your program should be able to reproduce the sample executions above for Valentina, Emma and Sofia.
Sample Execution for Subtask 5
What is your name? Sofia How many classes are you taking this semester? 4 What is the average time in class per week this semester? 3.2 What shall we call the 'everything outside of class' category? chill How many hours per week do you spend on 'chill' activities? 24 How many hours per day do you sleep on average? 6.55 Weekly time profile for Sofia: 38.4 class hours 24.0 chill hours 45.85 sleep hours 59.75 free hours
Your remaining subtasks can now add in the repeated characters to create the plot and align everything correctly.
Note that this breakdown into subtasks is just one suggestion. You can break them down any way you prefer. However, trying to write the code for the entire program without breaking it down is a bad idea.
Notes
-
Your program should only use Python features presented in Lecture 01 and Lab 01. In particular, your program can use:
- The arithmetic operators
+
,-
, and*
; - The string operators
+
(string concatenation) and*
(string repetition) - The built-in functions
float
,int
,len
,max
,print
,raw_input
,round
,str
. These are all explained in the Lecture 01 slides.
Your program should not use any other Python features that we have not studied yet, such as string methods, conditionals (i.e.,
if
statements), lists, loops, or recursion. - The arithmetic operators
- For a completely correct solution, spacing, alignment of colons, and the number of digits after a decimal point in a number are important. But you can receive partial credit for solutions that are not exactly correct.
-
You may assume that inputs are sensible, and the behavior of your program for nonsensical inputs is unspecified. This means that your program can do anything if an input is unspecied and still be considered correct. For example, if the number of classes specified is not an integer, the program could fail with an error message immediately, it could fail after reading in other inputs, or it could fail after printing the first line of the output display.
Here are inputs that are sensible:
- The name input may be any string, including the empty string.
- The number of classes is assumed to be an integer.
- The average time in class per week is expected to be a number (integer or floating point number)
- The number of extracurricular hours per week is expected to be a number (integer or floating point number)
- The number of hours slept per day is expected to be a number (integer or floating point number)
- The number of inputted hours or their total sum cannot be larger than the total number of hours in a week (168 hours). This would have as a result a negative value for the amount of free hours.
Toward the end of the semester, we will learn how to check that the inputs are sensible and then require the user to enter valid inputs.
Task 2: Graphics Scene
This task is a partner problem in which you are required to work with a partner as part of a two-person team.
The GraphicsScene
folder contains a copy of the cs1graphics
package. We have also included a copy of the cs1graphicsHelper
package (used in Lab). 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 abstract 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.,
# Beyonce and Jay-Z # CS111 Problem Set 1 # Graphics Scene # 02/01/2017
- Your file must appropriately
import
thecs1graphics
package (and thecs1graphicsHelper
package, if you opt to use it) - 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 include at least one
Layer()
in your scene, and that layer must contain at least 2 different instances of the classes listed in criteria 4 above (e.g., aCircle
and aPolygon
). YourLayer()
must appear in your scene at least twice. You may transform your layer usingrotate
,scale
andflip
- 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. Your image will appear in its original form in your graphics scene. Althoughcs1graphics
includes flipping, scaling and rotating, these operations do NOT work with imported images. If you try to flip/scale/rotate your image incs1graphics
, it will turn completely black. To avoid this, you may use Photoshop (or similar image-editing software) to manipulate your image to the desired size/orientation, and then import it into your scene. - You must position at least one object so that it is partially obscuring another object in your scene.
After completing this task, you must take a screenshot of your graphics scene, name it correctly, and upload it to the shared google drive folder here. See details below.
How to turn in this Problem Set
In both tasks you will take a screenshot of the output, which you will submit in addition to your code. Here are screenshot instructions.
Soft-copy submission (3 separate steps)
-
Submit your code (every student)
- Save your final
timeProfiler.py
file in theTimeProfiler
folder. - Take a screenshot of your output, similar to this example. Use your accountname as a filetitle, e.g.,
bknowles_timeprofiler.png
. It's okay if your output looks different, enter your own information, not ours. This file needs to be saved like the code file in theTimeProfiler
folder. - Each team member should save their
scene.py
file in theirGraphicsScene
folder. This file should contain a comment with names of both partners 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. - Note: It is critical that the name of the folder you submit is
ps01
. In other words, don't rename the folder that you downloaded. We have automated scripts to check your electronic submission: an improperly named folder will not count as a valid submission. - Drop your entire
ps01
folder in yourdrop
folder on thecs
server using Cyberduck by 11:59pm on Monday, February 6, 2017. - Failure to submit your code before the deadline will result in zero credit for PS01.
- Save your final
-
Submit your screenshot (one per pair of students)
Each pair of students in the course must upload a screenshot of their graphics scene to the the shared google drive folder. In order to do so, follow these steps:
- Take a screenshot of your graphics scene (screenshot instructions here).
- RENAME your screenshot with a short, unique name (a name that does not already appear in the shared google drive folder). Some good examples for screenshot names:
harryPotter.png, underwaterMonkey.png
, orfrozenScene.png
. When you fill out the Honor Code for PS01 form (in step 3 below), you will be asked to provide the name of your scene. - Drag your properly named screenshot into the shared google drive folder by 11:59pm on Monday, Feb 6, 2017.
-
Submit Honor Code for PS01 form (every student)
Fill out this form before 11:59pm on Monday, Feb 6, 2017. Points will be deducted if the form is not submitted on time.
Hard-copy submission
There is no hard copy submission. Pset submission is entirely electronic.