Wednesday, September 30, 2015

Exploring Snap! Code

Exploring Snap! Code

Work with a Partner Share one computer. Take turns typing and reading.
Snap! is a computer programming language. Programs are sets of instructions (called scripts) that tell the computer what to do. Since Snap! is a visual language, you will build your programs by dragging blocks (individual instructions) and snapping them together into scripts.
  1. Bookmark or write down the Snap! link. You will need it every day.
    Use the URL http://snap.berkeley.edu/run to launch Snap! in a new window (or tab).
  2. Build this script. There are instructions below. Then click on the script to see what it does.
    pen down, repeat 4 (move 50 steps, turn CW 90 degrees)
  3. Building a Script   (Yellow boxes are optional reading.) 
    This animation shows how to build the script. Drag one block underneath another to snap them together. The white bar shows where the block will snap.
    Creating a script
    Instructions
      Motion palette categories: Motion, Looks, Sound, Pen, Control, Sensing, Operators, and VariablesThe blocks' colors match their palettes: blue for Motion, green for Pen, yellow for Control, etc.
    1. Look through the eight palette categories shown at right to find each of the blocks you need for the script. Drag each block into the scripting area and snap them together.
    2. Adjust the numbers to match the script:
      pen down, repeat 4 (move 50 steps, turn CW 90 degrees)
    For You To Do
  4. Talk with Your Partner Discuss what this script does and why.
  5. Talk with Another Pair Discuss the behavior of the script with another pair. If the results are not the same, check that each script matches the model shown above.

Pair Programming Swap

Pair Programming Swap In this course, you will use a technique that professional programmers call pair programming—writing computer programs in teams of two. One partner writes the program; the other partner helps plan and helps catch errors.
Switch roles often, aiming for equal time in each role. If you haven't swapped yet, swap now. Pair Programming Swap
    Reference for the script that draws a square:
    pen down, repeat 4 (move 50 steps, turn CW 90 degrees)
  1. Experiment! What happens if you...
    1. Change the number in the move 50 stepsblock and click the script to run it again?
    2. Change the number in the turn right 90 degrees block and run the script again?
    3. Change the number in the repeat 4 loop?
    4. Click the clear block in the green Pen palette?
  2. You can click clear (or any other block) in its palette or in the scripting area to run it at any time.
    If you click a block that is part of a script, the whole script will run.
  3. Look back at the code that drew a square. Talk with Your Partner Discuss how each block contibutes to the overall behavior.
Pair Programming Swap
  1. Experiment more! Create a program that draws something. Below are other blocks that you may find useful. Find them by their color coding, and click on them to see what they do.
    go to x 0 y 0 point in direction 90 set pen color dark red set pen size to 1
  2. If you see some feature or code that you like, build something like it in your own program.
  3. Share Your Work with another pair. Discuss how each block contibutes to the overall behavior.

No comments:

Post a Comment