CS 202 Fall 2011

Homework #2 Due Monday 9/19 9:55am (before lecture): Create Art with Scratch and Solve Code Puzzles

This homework has two parts. In Part A, you'll use Scratch to draw an interesting picture. In Part B, you'll analyze different scripts written in Scratch and decide if they have the same functionality or not.

Part A: Art in Scratch (6 points + up to 2 points extra credit)

This part of the assignment is intentionally somewhat open-ended. You are to create a Scratch program that draws some scene or object that you find artistic or interesting. A great example is this program that draws a very cute pig.

For full credit, there are certain features that you must implement; we refer to these features as the specification.

  1. Your program must have a Sprite that moves around the stage leaving behind a trail of ink. This Sprite can have any costume (or appearance) that you like.
  2. The trail of ink must vary in both color (or shade) and in size as the picture is drawn.
  3. The pen must occassionally lift up and be put back down. For example, if your program draws both a pig and a barn, it will likely pick up the pen after drawing the pig and before drawing the barn.
  4. The pen marks must be cleared off of the stage when the Green Flag is Clicked. Optionally, the stage may be cleared at other points in time (e.g., when the user clicks a button or presses the space bar).
  5. The program should either not require any input from the user or just some minimal interaction. It is fine if the user must interact with the program a small amount to draw a picture (e.g., the user must click on random locations in order to draw a flower as in "7 - GardenSecret" in the Examples/Interactive Art included in Scratch). It is not okay if the user must supply all of the talent or creativity (e.g., "8 - ZenRockGarden").
  6. The drawing must not be entirely random. The drawing must be of some object or scene that most people can identify (even if it is an artistic rendition). It is fine to use some amount of randomness (e.g., the program could draw a different number of stars in the sky each time it is run), but the movement of the drawing Sprite may not be entirely random.
  7. The program must begin by showing instructions. For example, the program must state the picture that is going to be drawn. If the user is expected to interact with the program, it must describe how to do this.
  8. The program must show an image that you have imported from the web. For example, this image could be always showing as part of the background, it could be the costume of the drawing Sprite, or it could be revealed when the picture is completed.
You are welcome to add additional features to your program as long as you continue to meet the specification above. For example, you can add music, sound effects, multiple drawing sprites, stamps, and backgrounds. While you will not receive any additional credit for optional features, you may find they create an interesting and rewarding experience.

We hope that you create a picture that you like!


When implementing your program, you may find the following hints useful:

For each object drawn, you will want to put the pen down and then move steps and turn degrees to get the Sprite to draw the desired shape. You can choose the number of steps to move.

To develop your program, implement one piece of functionality at a time, and test it to get it right before moving on to the next piece. This is one of the great aspects of programming: you get to see the results of running your code! You don't have to get it right the first time!

When you are testing, you may find it useful to insert wait secs blocks. By pausing between blocks, you can more easily see what your Sprite is doing and perhaps what it is doing wrong!

To find an image to import into Scratch, we recommend using your browser and Google Images to find a suitable image. After you've saved this picture to your desktop, you can import the picture in Scratch as either a Background for the Stage or a Costume for a Sprite by clicking on "Import" under either of the applicable tabs (i.e., Backgrounds for Stage or Costumes for Sprites).

You may not use existing code that you find elsewhere, including the Scratch website. You may look at the behavior of existing Scratch projects for inspiration, but you should develop all of your code as a completely new project and not modify, re-mix, or build from any one else's code.

Extra Credit (Optional)

For extra credit, you may share your art project with the class. You can obtain up to two points of extra credit: one point just for correctly sharing and one point for getting a significant number of people to "Love It".

To correctly share your picture, follow these steps carefully:

  1. Save your complete project with a file name like "hw2-art".
  2. "Share" this project on the Scratch website by clicking "Share" and then selecting "Upload project to website". (Of course, you must be connected to the network to do this!)
  3. Use a web browser to go to the Scratch website and visit the gallery Fall11-HW2-Share. Click on the button on the right-side of the page saying "add my projects". In the pop-up box, select your project that you want to add and click "Accept".
  4. Verify that your project with the picture you like is showing up the gallery.

More details will be given in class about how to get others to vote for your picture so you can get additional points. This may include showing your project to everyone!

Part B: Code Challenge (4 points)

Can you figure out if different scripts are equivalent? Figuring this out can be tricky! Every little detail matters!
  1. You have a cat executing the following script. Specify in natural language english what the cat does over time. Be precise with the initial state and the exact sequence of actions over time.

  2. For each of the following nine (9) scripts activated by "When Green Flag clicked", state whether or not it results in the same behavior as the original script above. If the script results in different behavior, describe the new behavior. By behavior, we mean all of the output (either video or audio) from the program that is apparent to a user running the program.

    You may implement these scripts in Scratch if you want to check your answers, but you should be able to answer the questions by just looking at the scripts and thinking about how they will run.

You should write down your answers in a word or text editor of your choice. Please save and submit your file in one of the following formats: .pdf, .doc, or .docx.

Running Scratch

You are welcome to use any computing facilities for this project, as long as you have Scratch 1.4 installed. You can either download Scratch 1.4 from the website or use the Windows or Mac machines in the instructional clusters on the first floor of the Computer Sciences department. The hours and room numbers are available here.

Everyone in the class has a CS account. To activate your CS account, you go to one of the Windows machines in our instructional cluster, click on "Activate new account" and type in your UW ID number along with a new password of your choosing. You will then have an account on both the Windows and Mac clusters.

On the Windows machines, you can find Scratch in the menu for Applications.

Turning in your Homework

You should turn in your .sb file for Part A and your .pdf (or .doc or docx) file through your Learn@UW account. To do this, you can follow these steps:

  1. Login into LearnUW : "learnuw.wisc.edu" using UW NetID and `password.
  2. Click on the link "compsci202:Introduction to Computation" under student tab.
  3. Click the Dropbox option which is on Top-Left of your web page.
  4. Click the link to the corresponding HomeWork you need to upload. It directs you to a page where you can upload files.
  5. Upload the two desired files and submit them. For Part A, your Scratch program will be saved in a file with the extension ".sb". For example, if you named your program "homework2", then you will see a file with the name "homework2.sb" that you should upload. For Part B, you must submit a file in formats .pdf, .doc, or .docx.


Fall 2010
Time: MWF 9:55-10:45
Room: 1221 CS
Lab: 1370 CS (1st floor)

Prof Andrea Arpaci-Dusseau
Office Hours
Mon 11-12, Wed 11-12
7375 Computer Sciences
Email: dusseau "at" cs.wisc.edu

  • CS202 Home
  • TAs and Lab Hours
  • Lecture Schedule w/ Slides
  • Grading
  • Homeworks
  • Projects
  • Exams
  • Scratch Examples
  • Readings
  • Computing Resources
  • Outreach Opportunity
  • Interesting Links
  • Scratch
  • UW Computer Sciences Dept