Exploring Snap! Code
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.
-
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).
-
Build this script. There are instructions below. Then click on the script to see what it does.
- 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.
-
Adjust the numbers to match the script:
- Discuss what this script does and why.
- 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.
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.
Instructions
The blocks' colors match their palettes: blue for Motion, green for Pen, yellow for Control, etc.
For You To Do
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.
- Experiment! What happens if you...
- Change the number in the block and click the script to run it again?
- Change the number in the block and run the script again?
- Change the number in the loop?
- Click the block in the green Pen palette?
- Look back at the code that drew a square. Discuss how each block contibutes to the overall behavior.
Reference for the script that draws a square:
You can click (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.
If you click a block that is part of a script, the whole script will run.
-
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.
- with another pair. Discuss how each block contibutes to the overall behavior.
If you see some feature or code that you like, build something like it in your own program.
No comments:
Post a Comment