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

  1. Open the Assignment project.

  1. Perform each of the experiments (A-D) decribed in comments in the starter code several times.

  1. Talk with Your Partner

    You will record your answers on the checkpoint at the bottom of this page.

    • What does each reporter block report?
      who block does what block gossip block

    • What happens when you click this script (labeled D)?
      say (gossip) broadcast (your turn)

There is nothing exactly like say (gossip) or say (gossip) for (3) secs 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 a white rounded rectangle containing first the word 'DISPLAY' in all caps and then a smaller white rectangle containing the word 'gossip' in lower case 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 ( Settings menu gear icon ), 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 the author’s of the starter code 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.

The blocks we are exploring on this page are not part of Snap! but were made by the author’s of the starter code. In a couple pages we’ll learn to make our own blocks which is one of the most powerful moves in Snap! programming because it saves us from having to copy and paste code all over our programs. Instead we can give useful chunks of code a name and reuse them wherever we need them. That also means if we discover later on that we need to fix a bug in that code, we only have to change it once instead of finding every copy throughout our program.

Exploring a Second Sprite

  1. In the sprite corral, click on the green sprite named “Sprite(2)” to control its scripts and costumes.
    stage-and-sprite-corral

  1. Perform each experiment (A-C) several times.

  1. Talk with Your Partner What does broadcast do? You can record your answer on the checkpoint.

  1. Talk with Your Partner Discuss how who2 compares to who and how gossip2 compares to gossip. Record your answer on the checkpoint.

  1. Checkpoint

    The broadcast block sends a message to all the sprites. To set the message, click the down arrow and select “new…”
    broadcast block with menu open showing two options: your turn, new...

    For more information about the when I receive block, right-click (or control-click on a Mac) the block and select “help…”
    when I receive block with right-click menu open showing four options: help..., duplicate, delete, script pic...