Raspberry_Pi_Education_Manual

Notes:

The “if/else” block.

Take the little script that was in your “if” block and put it into the “if” bracket of an “if/else” block. The result should look like the screenshot below.

Is the dog old enough to go on holiday?

We also need to find out if the dog is old enough to go on holiday by herself. We will need to use a second “if/else” block. Drag it onto the Scripts tab, but don’t attach it to your script just yet – leave it floating by itself.

We’re going to ask the dog how old she is. Depending on her answer, there are two possible outcomes:

1. Her age is less than 10, and she’s not allowed to go on holiday. 2. Her age is greater than 10, and she is allowed to go on holiday.

If the dog’s age is less than 10, we want the cat to say, “Sorry dog, you’re too young to go on holiday.”

The “less than” operator.

Using your “less than” (<) operator, as well as blocks from Variables and Looks, build the piece of script that you see in the screenshot on the next page.

Build this script inside the “if” bracket of your second “if/else” block.

A beginner’s guide to Scratch

31

Made with FlippingBook flipbook maker