Intro CS Assignments
Assignments by week:
Fall Term: 1 2 3
Winter Term:
Spring Term:
Monday, September 17
Description
Variable Declarations and Scope
Homework
  • Read the following sections on the Processing website:
  • Create a sketch that does the following:

    • A circle with diameter 50 follows the mouse everywhere on the screen.
    • When the circle is on the left half of the screen (horizontally), it's filled blue.
    • When the circle is on the right half of the screen (horizontally), it's filled green.
    • When the circle is on the top half of the screen (vertically), it's stroke is black.
    • When the circle is on the bottom half of the screen (vertically), it's stroke is red.
    • Note that the vertical and horizontal assignments are independent; for example, if the mouse is in the lower-right-hand corner of the screen, the circle should be green with a red border.

    Here's a sample:

    Your browser does not support the canvas tag.

Wednesday, September 19
Description
Conditionals
Homework
  • What is the value stored in the variable x in each of the following? (Note, results may not be obvious!)
    1. int x = 79 % 12;
    2. int x = 12 / 5;
    3. int x = 35 / 7;
    4. float x = 15.0 / 2.0;
    5. float x = 65.0 / 4;
    6. int x = 250 * (4 / 5);
    7. float x = 250.0 * (4.0 / 5.0);
  • Write a program that draws a new shape on the screen wherever the user clicks the mouse. If the user clicks in the top half of the screen it should be a square. If they click on the bottom half of the screen, it should be a circle.
  • Write a program that draws a circle at a random location on the screen every time the user presses the mouse. The color of the circle should alternate between red, green, and blue (that is, the first should be red, the second green, the third blue, the fourth red, the fifth green, and so on).
Thursday, September 20
Description
Review of Variables and Conditionals
Homework
  • Create a program that starts with a black background. The background should fade smoothly up to white, and then fade smoothly back down to black (it shouldn't jump from white back to black; it should fade smoothly).
  • Read Processing's review of trig functions.
  • If you had trouble with the homework on previous nights, consider re-attempting one of the problems. Or, modify one of your existing problems to try new things.
  • Bonus question (try if you have time, but don't worry if you don't): write a program that produces this result:

    Your browser does not support the canvas tag.

Friday, September 21
Description
Review
Homework
  • Study for your first test during next class. Anything we've learned so far is fair game (see the reading assignments from previous weeks). Examples of questions I might ask include:
    • Sketch the drawing produced by some lines of code
    • Write the code to produce a specific drawing
    • Evaluate arithmetic expressions (like "x = 15 / 7")
    • Write short programs that draw shapes, access the size of the canvas, and the position of the mouse
    • Create colors
    • Use random numbers