Raspberry_Pi_Education_Manual

Notes:

We’re not finished yet. We’ve told the program to add our numbers, but we need to store that answer in one of our variables.

From Variables in the Blocks Palette, drag “set [first_number] to [0]” to the Scripts tab. Change “first_number” to “result” and drag your “add” operator onto the number “0”. Your block should look like this:

Finally, we also need to tell Scratch to display the answer to the sum. Otherwise, it will keep it to itself (and that’s no good to us).

Click on Looks in the Blocks Palette. Select “say [Hello!]” and drag it on to the Scripts tab. From Variables, drag the variable “result” and drop it onto “Hello!”. The image below will show you what we mean.

and

And that’s it! I have included the whole program below. We’ve added in some extra blocks, to make the cat a bit chattier but the basics are the same as the script we built above.

Use this screen- shot to build the whole script. And remember, each time you want the cat to do another sum you will have to click on the green flag.

Tip...

Make sure all the blocks snap into place properly, especially when you have to snap blocks on top of other blocks.

But hang on a minute: if you tried to make the cat do all the homework you will have noticed a big problem.

The cat can only do addition! Don’t panic – a quick edit to change the program slightly will do the trick.

A beginner’s guide to Scratch

27

Made with FlippingBook flipbook maker