On completion of this lab you should be able to write more complex programs demonstrating flow of control (i.e. Sequence, Selection and Iteration) whilst using variables and operators.
To create a variable in Scratch:
To view the value stored in your variable, click on the checkbox beside the variable name, as shown in the screen shot below:
As the code in this example is building on the code you wrote for SomethingFishy4, we will make a copy (i.e. clone) of the SomethingFishy4 file and call it SomethingFishy5. To do this:
Does it work as expected?
In this exercise, we want your sprite to count from 1 to 20.
Using a loop, get your sprite to count out all the even numbers from 1 to 20 e.g.
Using a loop, get your sprite to say the running total of all even numbers from 1 to 20 inclusive e.g.
Using a loop, get your SpaceShip Sprite to countdown from 10 and then blast-off.
The solutions for this lab are here.
You will notice that there are two solutions for each of the first three Exercises above. The reason is that there are multiple ways to approach a problem and each one is correct!
These exercises are quite difficult and we don't expect you to be able to complete them straight away. They are challenges for you to investigate and figure out at a later date, should you wish.
For each challenge exercise listed below, open a new Scratch project.
At the bottom of the page, we have included the solution.
In this exercise, use a loop to get your Sprite to say the lyrics to the song, Ten Green Bottles.
An example of the first verse is below. Keep saying this verse, reducing the bottles by 1 each time until no green bottles are hanging on the wall.
In this exercise, your Sprite should choose a random number between 1 and 20.
If the number is even, your Sprite should say Even and display the number.
Likewise, if the number is odd, it should say Odd and display the number.
This processing should continue until the number 7 is chosen at random.
Hint: You will need to use the mod operator for this exercise. When a number is mod by another number, the answer is the remainder. For example, 6 mod 3 is 0 whereas 7 mod 3 is 1.