CSC 160 Spring 2014 - Homework 2 (100 points)
Assigned Feb 17, due MON Feb 24
1) Assignments submitted on Moodle with time stamps during
class time (Mon or Wed 4:15-5:30pm) will be given a grade of ZERO.
2) Start this homework as soon as possible so that you have time to get any help you may need
from the instructor or course tutor prior to when the assignment is due.
3) Do not start the exercises until to have fully read and fully understood the corresponding
textbook sections. If there is something you do not fully understand, you must contact
the instructor or course tutor prior to starting the assigned exercises.
[10 pts.] Another PSP Handout
Read the Chapter 3 handout. (Handout will be given out in class on Mon 2/17.)
Start the Time Recording Log. For the next week, fill it out anytime you do an activity related to this course.
Submit on paper in class by the due date OR Moodle with the filename "hw2[LastName]PSP".
[20 pts.] Chapter 2A
Read Sections 2.1-2.3 of the textbook.
Do Exercise 2.1.3 in DrRacket, with the specific directions given here:
In the Definitions Pane:
a) Store a picture in a variable.
b) Then define another variable named two-copies
whose value is two copies
of that picture, one beside the other, by using the previous variable.
c) Then define a third
variable named six-copies
whose value is a six-pack of the
picture, 2 wide by 3 high, by using two-copies
.
d) Then press Run.
In the Interactions Pane:
Type the name of the first variable
into the Interactions Pane and press Enter. Make sure you got the result
you expected. Repeat for the other 2 variables.
Save the Definitions Pane to your computer or flash drive with the filename "hw2a[LastName]Def.rkt".
Save the Interactions Pane to your computer or flash drive with the filename "hw2a[LastName]Int.rkt".
Upload these files to Moodle, using the link for HW2. (Do not click Send for Marking yet, so that you can upload the other files in this assignment!)
[25 pts.] Chapter 2B
Read Sections 2.4-2.6 of the textbook.
Do the following exercises on paper:
2.4.2: Draw a box diagram to prove that
(rotate-cw calendar)
is a legal expression. Assume that
calendar is already defined.
2.4.3b: Draw a box diagram for each of the three
expressions in your solution to Exercise 2.1.3* to prove they are all legal
expressions.
2.5.1, with the specific instructions given here: Show the sequence of steps the Stepper would take in
evaluating the expression two-copies
, assuming that the definitions from 2.1.3 are above it in the Definitions Pane.
Reminder: At each step (but the last), you need to underline the sub-expression that's about to
be replaced (i.e., the way Exercise 1.7.1 is done in the textbook).
Submit on paper in class by the due date OR on Moodle with the filename "hw2[LastName]Paper".
[45 pts.] Chapter 3A
Read Sections 3.1-3.4.2 of the textbook.
Do the following exercises in DrRacket:
3.3.3, with the specific instructions given here:
a) Define a variable named solid-green-box
whose value is a solid
green rectangle. Use a width of 10 and a height of 20.
b) Define a variable named
outline-blue-box
which is what it
sounds like. Use a width of 10 and a height of 20.
For parts c and d, use only the variable names. Do not use the pictures
of the rectangles or the expressions using the rectangle operation, or only half
credit will be given.
c) Write an expression to put the solid box above the outline of a box.
d) Create a two by two checkerboard where the upper left and bottom right
corners have the solid box, and the upper right and lower left corners
have the outline of a box.
3.4.4: Write the function contracts for ellipse
, circle
, and
star-polygon
only.
For each argument, include its data type then describe what that argument is
in parentheses. (Make sure this exercise is commented out, as discussed in
Sections 3.4.3-3.4.4 of the text.). Note: The contract for
triangle
is omitted from this exercise.
Save the Definitions Pane to your computer or flash drive with the filename "hw2b[LastName]Def.rkt".
Save the Interactions Pane to your computer or flash drive with the filename "hw2b[LastName]Int.rkt".
Upload these files to Moodle, using the link for HW2.
GRADING |
Question |
Point Value |
PSP |
10 |
2.1.3 |
20 |
2.4.2 |
5 |
2.4.3b |
15 |
2.5.1 |
5 |
3.3.3 |
30 |
3.4.4 |
15 |
Total |
100 |
Last Modified: 2/24/14