Page 2: Making Programs Talk
Unit 1, Lab 2, Page 2
On this page, you will experiment with an existing program as an introduction to the project.
Exploring Custom Blocks
You’ll need to be logged in to save to your account. You know that you’re logged in if you see a filled in cloud at the top right of the Snap! toolbar .
You may wish to review how to log in at Unit 1 Lab 1 Page 1: Getting Started with Snap!
Perform each experiment (A-D) several times.
-
- What does each reporter block report?
- What happens when you click this script (labeled D)?
- What does each reporter block report?
There is nothing exactly like or on the AP Exam because they don’t have sprites and speech balloons, but their way of showing this text to the user is
DISPLAY(gossip())
if it’s written as text or if it’s shown as blocks.
You won’t have to be able to write code in this notation on the AP exam. You just have to be able to read it so you can answer questions about it.
Would you like to make the blocks bigger?
In the Settings menu (), choose “Zoom blocks…”, and adjust the slider.
Abstraction is the most fundamental idea in computer science, but it’s hard to define until you’ve seen some examples. The most basic kind of abstraction is to give a name to something in a program. For example, here we gave the name who
to the idea “pick an item at random from this list of people (or cats).” This is called procedural abstraction because we use a procedure (a block) to name the idea. This makes your code readable. You’ll see other kinds of abstraction later.
If you find yourself wanting to copy and paste code from one place to another without changing it, then give it a name (open a Block Editor and paste the code there) and call your procedure in both places. If you discover later on that you need to fix a bug in this code, you only have to change it once instead of finding every copy throughout your program.
Exploring a Second Sprite
In the sprite corral, click on the green sprite named “Sprite(2)” to control its scripts and costumes.
Perform each experiment (A-C) several times.
Write down what
broadcast
does.Discuss how
who2
compares towho
and howgossip2
compares togossip
.Make Sprite(2) tell Sprite to respond. What happens?
The
broadcast
block sends a message to all the sprites. To set the message, click the down arrow and select “new…”
For more information about the
when I receive
block, right-click (or control-click on a Mac) the block and select “help…”