Scratch FYK3
Scratch FYK3
change SCORE by 1
move 2 steps
go to random position
● 3. Sprite Sensing: the 3 Amazing Sensing Blocks (for touching, distance, attributes)
- including Colour Sensing, the User Input box and the Answer variable, Sprites in Draggable Mode
● 5. Variables & Lists: Counting, Multiples, Keeping a Game Score, using a Timer, a Variable with a List
- variable Readouts in Normal, Large and Slider Mode
- variables in Nested loops to create Rows (Across and Down)
- filling a List; by Direct input, by using the input block, by Answering Questions for input
- More Sprite uses: Animal pictures as costumes, Create a New Sprite, Use an invisible Sprite
38
Fun With Easy Revision
Saving Your Projects Drag to Copy a Sprite’s Code
File Edit Tutorials Cat on its 1 Log in and start a new project. Save it as the Join Scratch Sign in
New
Bat and Bear. If you are offline on the Scratch
Desktop, save to your destination folder.
Save now
2 Get the Mountain backdrop from the library. 5
Save as a copy
3 Delete the cat and get the Bat from the Animals
Load from your computer
category in the Sprite library. 2
Save to your computer
4 Code the Bat as follows.
Scratch gives you the option to work online or The Bat Should Fly Left to Right.
offline. If you intend to work online and you when clicked the Bat
Press and Drag
would like to save your projects, it is is the
SCRATCH for Your Kids © Seamus O’Neill 2021
6 current
recommended that you set up a Scratch ID. If you Bat sprite
want to enjoy Scratch on an iPad, you must be
online. You can download the Scratch Desktop if 5
you would like to use Scratch 3 offline on a
18
desktop and laptop. With the Scratch Desktop Drag - Copy the Bat’s Code to the Bear
you don’t need a Scratch ID. However, if you Bear-walking
5 Get the Bear Walking sprite from the library.
want to share an offline project and show it to
6 Press and Drag the Bat’s code from the top onto
your friends, you will need a Scratch ID. Bear walking
the Bears’s thumbnail. When the tip of the
Scratch Desktop mouse-pointer is over the centre of the Bear’s
the wobble
File Edit Tutorials Cat Exer the code from the Bat
thumbnail DO NOT RELEASE it until the Bear’s
copies to the Bear thumbnail wobbles. When you see the wobble
New
release your hold. The script will copy to the
Load from your computer 50 x 10 = 500 steps Bear. If necessary drag the code again until it
Save to your computer copies. Select the Bear’s thumbnail and you will
8 see that it has a copy of the Bat’s code.
Log in and code this Sample project of 6 blocks:
Here is the script: (1) when the cat is clicked (2) Make the Bear 7 Set the Bear at the bottom of the stage at y: -150.
repeat 200 (3) rotation style all around (4) move Walk from Run the code and you should see the Bat and
20 steps (5) turn 10° (6) bounce on the edge. If Right to Left Bear both move from left to right.
exact, the cat will finish on its head at x;-16, y:-9 The Bat began on the left at : -250. Remove the minus to set the Bear’s starting
facing -90°. Save the Project, as Cat on its Head. location on the right at x: 250, y:-150. You must make the same change in x:
inside the repeat (4) loop. The Bat began with point in direction (90). Make
Off line: You need a destination folder on your the Bear point in direction (-90). Run the code and Save to update your work.
computer where you can save your Scratch
projects. Give the destination folder a name, e.g. Understand the Bat’s code: The Bat flits from the left (at x: -250) to the right side of the stage (at x: 250)
my Scratch projects. Complete the Cat on his by 50 loops of 10 steps. This is highlighted by the dashed line in the inside loop. It then returns to the
Head project in the Scratch Desktop. Go to File left and crosses to the right again, doing this a total of 4 times. As long as the total inside the dashed
> Save to your computer and save Cat on his Head lines is between 480 and 500 you can change the figures. The Bear should be slower than the bat. Try this
to the folder my Scratch projects. Check online. on the Bear : Change repeat (50) by (10) steps to repeat 120 by (4) steps. Make the Bat cross 8 times.
Check the facts of Cat on its Head at the Bat and the Bear is shared at https://scratch.mit.edu/projects/422673755
https://scratch.mit.edu/projects/444500420 Take it to the next level?
39
See the code inside the Bear Story at https://scratch.mit.edu/projects/378930326
Fun Palettes: Sprite Sensing
Sensing Palette and Blocks Colour Picking
Code Costumes Sounds The Cat and the Ball Bursting Balloons
Sensing
12 of 18 blocks
Motion
touching mouse-pointer ?
Looks
touching color ?
color is touching ?
Sound
distance to mouse-pointer Backdrop: Blue Sky
SCRATCH for Your Kids © Seamus O’Neill 2021
40 Descriptive names of all Sensing blocks: touching () ; touching (color) ; colour () touching (color) ; distance to () ; ask () ; (answer) ; <key () pressed> ;
<mouse down?> ; (mouse x) ; (mouse y) ; () of () This is the attribute reporter whose two lists change depending on which sprite is selected;
set drag mode ; (loudness) ; (timer) ; reset timer ; (current year) ; (days since 2000) ; (username) ;
Fun Palettes: Data Types in Scratch Ask and wait for Input
Operators Palette and Blocks
Code Costumes Sounds Just Click an Operator
What is 3 quarters of 20?
You can click on any operator
Operators: all 18 blocks to get a hint box that tells you
say What is 3 quarters of 20?
Motion The four Maths operators ( +, –, x, ÷ ) its value and what a sprite
report the result of the operation on the would report in a say () block (plain text) string data
two numbers in the input windows. Try speech balloon.
Looks 3 quarters of 20 is 15
typing a letter in a Maths operator.
pick random 1 to 10
minimum and maximum of the two
Events values. The defaults are 1 and 10. say join 3 quarters of 20 is 20 4 3
2+2 4
50
this is a solution ALGORITHM
greater than, less than and equal to false
Control 50 compare two values and report true or
false. They are called relational operators. 2 2 4
Code, then click the duck.
50
join apple banana join () () links two values together and Scratch regards b as if it was else
reports the result. two letters with a plus sign
between them. It regards say Wrong answer. Click me and try again.
letter 1 of apple
The words ‘apple’ and ‘banana’ are holding text. only 4 = 4 or c as a an
length of apple
The blocks are useful for text handling. E.g. See operation or calculation What is 3 quarters of 20?
Length of a Name p. 43 and Spell a Word p. 47 which equals 4. The coder uses the
apple contains a ? division and multiplication operators to
About the Operators Palette construct the correct solution algorithm. The
There are no stack blocks Operators. All are rounded or angled (Boolean) coder has to know the Maths in order to code
mod reporters. Scratch uses Operators to code Numeric or String data. ‘Numeric’ the algorithm correctly. Scratch checks the answer
from the user against its own built in calculator. An
data refers to numbers operating ( +, – x or ÷) on each other. ‘String’ data incorrect answer brings the user back to the start.
round refers to plain text (letters or numbers). For students of mathematics, it is
useful to know that the drop list in the abs of () block has fourteen Maths Input the answer and click to confirm.
abs of functions such as square root, sin, cos, tan, log, etc.
15
Solution Algorithm is shared at https://scratch.mit.edu/projects/430591659
Descriptive names of all Operators: addition reporter ; subtraction reporter ; multiplication reporter ; division reporter ; pick random ; greater than ;
greater than ; less than ; equal to ; <> and <> ; <> or <>; not <> ; join reporter ; letter () of () ; length of () ; < () contains ()> ; () mod () ; round () ; abs of () ;
41
Fun Palettes: Mathemagic
Code the Solution Algorithm More Solution Algorithms
22
What number is
6 more than 38 ? The ask () and wait block makes the sprite when clicked
ask a question in a speech balloon, and What is 2 thirds
of 18 ?
give the user an input box to type the answer.
answer The light blue answer reporter stores whatever say Click me for a question.
the user types in the box, (right or wrong).
Duck
type your answer here when this sprite clicked “ 10 ”
Code the Duck with the two scripts.
If the question is ‘What is the capital of France? Scratch does not ask What is 2 thirds of 18 ? and wait Change the question if you like.
have the answer but the coder can give Scratch the answer. If the
SCRATCH for Your Kids © Seamus O’Neill 2021
user types the answer as Paris (but the coder gave Scratch the if answer 18 3 2 then
answer as Athens), then Scratch accepts Athens as correct and Paris
as incorrect! Maths in Scratch doesn’t work like that. The coder Why does the code need
say Correct.
codes the solution algorithm not the answer. Scratch has its own two Maths Operators to code
the correct solution algorithm
built in calculator. If the solution algorithm is stop this script to answer this question? 23
correct, Scratch will have the correct answer.
when clicked else “9”
Code the Cat with the two scripts.
say Click me for a question. say Wrong answer. Click me and try again. for 2 seconds
Cat
say What is 2 thirds of 18 ?
when this sprite clicked
ask What number is 6 more than 38 ? and wait Code each animal sprite with two similar scripts to the duck.
Deduce the solution algorithm from the speech balloons.
Did the coder
if answer 38 6 then code the correct
solution algorithm? What number is What number is
5 less than 52? double 18?
say Correct. The coder has to know
the Maths in order to code
stop this script the solution algorithm.
else
What number is 3 more
What number is
say Wrong answer. Click me and try again! for 2 seconds than a quarter of 20?
half of 30?
28 31
code is not
(27 + 33) - 26 (34 + 29) - 36 absolutely
necessary.
1 35 2 27
24
17 19
SCRATCH for Your Kids © Seamus O’Neill 2021
script
1 when clicked 1 of 2
if answer 28 35 17 then
The above two-step sums are difficult for children too young to code. Those
say join answer is CORRECT
working with younger children might create a resource with easier sums but
with the same code structure. Use it to support homework and Maths lessons.
speak join answer is CORRECT
else
1 answer 9 18 2 answer 13 7
say Click me and try again
3 answer 15 11 4 answer 24 8
You are given a starter variable with the name, You must set the value to (0) before the say We have lift off
Variables
my variable, which you can use, rename or loop and change the value by (1) inside it.
delete. Code the Duck with a new variable The order of the blocks inside the loop, speak We have lift off
‘Count’. Counting is changing a number. because the duck should say “one” to start.
My Blocks
Text to The Variables Palette
Speech
A variable is a value that changes or varies. Start
with the set (variable) to () and in each iteration
Text to
Speech of a loop use change (variable) by a specified
amount. Scratch keeps a record of the changing
Text to Speech value in its memory. Tick the box beside the
Make your projects talk
variable reporter to see a readout mode.
A headset is
speak hello recommend. The Text to Speech Extension
Text to Speech allows synthesised speech in a We have lift off.
set voice to alto
Choose
Extensions
alto or tenor. project. It works well when the speak () block
is used after the unlimited seconds say () block.
set language to English
Readout,
ranging Maximum value
from 2 to 12
12
How many letters in my name?
Cancel OK
8
I’ll count in any
when clicked
Multiple to 12.
26 Correct. There are 8
letters in my name.
A headset is
when this sprite clicked recommend. Code me with the same
question as the hedgehog.
6, 12, 18, 24 …
30, 36, 42, 48 …
Zebra
60
How many letters in my name?
…66, 72 8
Wanda
Get the 30 px grid, by name Xy-grid-30px. You
need two variables Across and Down in slider
Script 2 of 2
mode. With the limitations in mind, set the slider
draw a SNOWFLAKE
range to min of 2 to max of 10. The size of the - a small white dot
orange at 80% is about the size of a grid square. about 4 x 4 canvas
squares in the centre
Code the Orange of the Paint Editor
Code the Orange Script 2 of 2
Script 1 of 2 Orange Script 1 of 2
the original snowflake sprite
Orange
The repeat ‘in Pond’ (e.g. 16) inside the dashed lines
set TOTAL to answer creates 16 self-clones (working copies) DRAG the
of the frog randomly located Script 3 of 3 on the Frog. frogs one
in the open area of the pond. The display box by one
set in Pond to answer
when I start as a clone becomes visible
Script 3 (the clone script), the
when the input
broadcast set Total instructs each clone to be display 2 + 14 = 16
visible, and draggable and show This is the clone script. box disappears box
when dragged to touch the
repeat in Pond
Lily Pad two variables change
Make a sprite with 19 costumes from
set drag mode draggable 12
to reflect 1 extra frog on the costume 1 to costume 18. Make the
Number
create clone of myself Lily Pad and one frog less (-1)
wait until touching Lily Pad
19th costume costume 0
costume 12
in the Pond. Each clone
set x to pick random 20 to 160 will be smaller by 30% Watch, record and Script 1 of 2 on
to save overcrowding change in Pond by -1 discuss the various when clicked the Number sprite
set y to pick random 0 to -60
on the Lily Pad. The partitions of the
clone will emit a Croak change on Lily Pad by 1 target number. switch costume to costume 0
sound.
change size by -30
say Now drop us onto the Lily Pad one by one. for 3 seconds when I receive set Total
play sound Croak until done Script 2 of 2 on
hide The actual (original) sprite gives the instruction to drag each switch costume to answer the Number sprite
cloned frog onto the Lily Pad. It must hide or be counted as an extra.
Set the Rotation centre of the sprite. switch costume to costume1 necessary in this game to be able to
Name your sprite label 1. drag a word label to touch a picture.
set drag mode draggable
3 Costume 2: The label 1 sprite needs a second costume. Duplicate When the player drags the word ‘mouse’
forever to touch the picture of the Mouse.
the costume in the Costumes Editor.
x: -200 y: -150 is the position of this
if touching mouse then
1 duplicate 2 Delete the word and sprite at the start and at the finish
mouse export draw a tick mark in go to x: -200 y: -150 The label shows the tick
costume 1 costume 2
its place. when the words correctly touches
delete
the Mouse and returns
switch costume to costume2
to its starting position I’m a mouse
4 Code the label: You only need to code label 1. When you duplicate
label 1 the code will copy and you make small changes at the dots. broadcast squeaks
5 Use duplicate to make a total of 6 ‘Mouse’ labels else TOUCHING EEEK!
sprites
Under the stage, and depending on your device, right
click (or press and hold) on the label 1 thumbnail. go to x: -200 y: -150 mouse
mouse
Duplicate label 1 and make small changes in
label 1 Select duplicate and it will make a copy of the label 1 the code of labels 2 to 6 at the dots (step 8).
sprite with the name label 2. Repeat duplicating until X5
duplicate you have 6 ‘mouse’ labels. All the sprites will have the There is one script on the picture sprite
export same colour and size and will be numbered label 1 to 7. Code the picture sprite
What happens when the word
delete 6. All the labels will have the same code as label 1. Mouse touches the picture sprite?
when I receive squeaks
mouse mouse mouse mouse mouse mouse The broadcast makes the sprite play a
label 1 label 2 label 3 label 4 label 5 label 6 play sound squeaks until done squeak sound and also say “I’m a mouse”.
6 Space each label 80 px apart at y: -150 and Edit changes (step 8)
say I’m a mouse X5
mouse frog chick bear lion dog Squeaks
word mouse word frog word chick word bear word lion word dog
8 Open each label one by one in the Costumes Editor and make changes
7 Code the Mouse picture sprite with the short script. Drag copy (at the black dots) to the name, colour and x: position. Leave the ‘mouse’
the script to each animal picture and make small changes (step 8). unchanged. See the positioning and the full code on the next two pages.
Drag-a-Word is shared at https://scratch.mit.edu/projects/446619719
48
Fun Palettes: Drag-a-Word
How to Use the 20 Pixel Grid for Layout
180
9 Use the layout information in this picture to make The labels measure 3 squares by 1.5 and are spaced out 80
changes to the duplicates of the code on each picture 160 pixels apart. It is not necessary to be as exact with the
sprite and its matching draggable word sprite. You need animals as they are different shapes, but use the grid
to make the changes, where indicated by the black dots. 140 squares as a guide to sizing and positioning.
80
SCRATCH for Your Kids © Seamus O’Neill 2021
Chirp
40
Bark Grunt
20
-240 -220 -200 -180 -160 -140 -120 -100 -80 -60 -40 -20 0 20 40 60 80 100 120 140 160 180 200 220 240
-40
-60
Bear Mouse Frog
-80
x: -200, y: -150 x: -120, y: -150 x: -40, y: -150 x: 40, y: -150 x: 120, y: -150 x: 200, y: -150
-140
-160
mouse frog chick bear lion dog
-180
word dog word frog word chick word bear word lion word dog
out of it than
the Muffin
the next.
a rate of 2 steps to pounce.
After 5 bites This is a game of chance. The
the player likelihood is that the Muffin will
gains 3 bonus points and
pop up beside a cat, the Mouse
the Muffin is restored to
costume 1 again. will get too near it and be caught.
51
Fun Palettes: Lists
List Blocks Fill a List Directly Fill a List by Answering Questions
Code Costumes Sounds A variable can store only one piece of data at a
Code Costumes
time. A list can store many items of data all at Sounds
33
Make a List once. Each item of a list can be identified by its
place number, e.g. item 1 etc. To fill a list directly 1 Create this New Sprite
Motion
just click the + and enter the data. You can also This is a very unusual Sprite. It has
New List
fill the list using the insert block. Data in a list can costume 1
a different animal for each costume.
Looks be either number or string data. Here the comma 2 Get the crab from the Sprites library
New list name: is string data. It is not common to mix data types. and delete costume2. Rename the
Count in Sevens The number of items in a list is called its length. costume 2 crab to Animals. In the Costumes
Sound library (see p.21) get 9 more animals
For all sprites For this sprite only 3
and add them as Animals sprite
SCRATCH for Your Kids © Seamus O’Neill 2021
Operators
delete all of My list + length 0 = + length 6 = costume 6
7
Variables When you have filled the list with 12 items …
insert 1 at 1 of My list
costume 7
7, 14, 21, 28, 35, 42,
49, 56, 63, 70, 77, 84 8
My Blocks replace item 1 of My list with 1 Create a New List, Creatures
costume 8
the name
item 1 of My list say Count in Sevens Creatures will Creatures
9
help you to
distinguish (empty)
item # of thing in My list 28 costume 9
the list from
10
the Animals
length of My list sprite.
say item 4 of Count in Sevens costume 10
My list contains thing ? Don’t fill the
list directly.
12 You will fill it
show list My list by answering
Extensions
the Cat’s + length 0 =
picture quiz!
hide list My list say length of Count in Sevens
52 Names of List blocks: list reporter; add() to ; delete () ; delete all ; insert () at () ;
replace item () with () ; item (); item # of; length of; (list) contains ()?; show; hide;
See Animal List at
https://scratch.mit.edu/projects/438075982
Fill a List from Answers (contd.) Fun Palettes: Text in Lists
To start, the Creatures list is empty. The Spell-a-Word
Animals sprite displays costume 1, which when clicked Word as list
carrot
delete all of Word as list Clear your list at the start
when clicked Cat set letter number to 0 variable = 0 A headset is recommend, although the
speak code is not absolutely necessary.
ORDER:
delete all of Creatures speak Type the name of any vegetable.
the ask must
repeat 10
be before the
broadcast ask Type the name of any vegetable. and wait Type the name of a vegetable.
34
ask Name the animal. and wait repeat length of answer Example: If you type carrot (6 letters),
length of (answer) = 6,
broadcast ask Question and wait change letter number by 1 the change by 1 and insert will repeat (6) times
the 1st letter
add answer to Creatures insert letter letter number of answer at length of Word as list + 1 of Word as list
finally, the cat says if your word is ‘carrot’ this code will insert ‘c’ 1st place in the list by name Your word
the full list of animals.
say Creatures set letter number to 0 In this project, the name of the list is Word as list (your
There are no commas
to separate the names input word) and the variable is letter number. If you
as that adds an extra repeat length of Word as list input a phrase, the space will count as a letter e.g.
Creatures complication. ( It would
be easy if input answer
Brussels Sprouts would count as 16 letters!
1 crab change letter number by 1
were to finish with
2 rabbit a comma.) The List and Variable blocks are grouped together in
say item letter number of Word as list
the Variables palette, because they are often used
3 chick together. One way to fill a list is to have a variable
speak item letter number of Word as list to feed items into it.
4 fish
5 fox Always start with delete all and with the variable set
c-a-r-r-o-t
6 mouse x say Word as list at zero. The length of (answer) sets the length of the
continued: list. The insert block adds letter 1 to the list at length
+ length 6 = giraffe, penguin,
speak Word as list of list +1 because the list is zero in length after the
lion, beetle
delete all. The plus 1 adds the letter as item 1.
Spell-a-word is hared at https://scratch.mit.edu/projects/438083231 53
Fun Palettes: A Game of Luck with an Invisible Sprite
New Sprite & New Costume
Fly sprite: There is no fly in
Code Costumes Sounds the Sprite library, but it is
1
quite easy to create your
Costume costume 1
Group Ungroup Forward Backward Front Back own. The fly will buzz
Costume1
Fill Outline 1
around, while the frog’s eyes
Copy Paste Delete Flip Horizontal Flip Vertical follow its movements. When
it approaches the invisible
‘X’ sprite, the frog’s tongue
will shoot out to eat the fly.
1. Paint (Create new) a Fly Sprite A variable will keep track of
the flies eaten in 30 seconds.
SCRATCH for Your Kids © Seamus O’Neill 2021
it and delete the tongue on The invisible ‘x’ marker sprite: Use ghost effect
costume 1. on the X-Button from the Sprite library to mark
an invisible spot on the stage at the tp of the
1 frog’s extended tongue (costume 2)
Open the Paint Editor to paint (create) a new sprite. Draw a fly out of duplicate
three ellipses. Position the fly’s nose at the centre of the canvas. frog Code the Invisible Sprite
export
2
Code Costumes Sounds delete
frog 2
invisible
35
1 Costume costume 1
Group Ungroup Forward Backward Front Back
1 Script
Frog’s eye sprites: Make two
frog
Fill Outline 1 duplicates of the frog and
Copy Paste Delete Flip Horizontal Flip Vertical
2 delete everything except the
left eye for one sprite and the
frog 2
2. Give the Frog a New Costume right eye for the other. Snap
with no extended tongue. the rotation centre of each
eye sprite to the stage centre. Create two variables: Name one variable Flies
Name costume 1 is no tongue. (See page 14). The eye sprites Eaten and name the other Timer.
Name costume 2 tongue should be the same size as
set Flies Eaten to 0
the frog’s eyes (at 200%)
The two eye sprites will go
Flies Eaten
on top of the frog’s eyes and timer
Choose a Sprite their code will make them Rename variable
point continuously in the Delete the “Flies Eaten” variable
direction of the moving fly.
Frog and Fly project https://scratch.mit.edu/projects/254019771
54
Code on Fly (2 Scripts) Code on Frog (3 Scripts) Code on the Left Eye Sprite (1 Script)
55
Fun Palettes: Pong Game for a Single Player
A Game that Uses All the Palettes Brief Notes and Suggestions
This Pong Game is played by a single player who must Make two variables Score and Timer. Instead
make the highest possible score before the timer runs of playing for 30 seconds, you could make the
out or by the time the Ball touches the red bar. game longer by increasing the ‘set timer to’
36 more than 30 (whatever suits). Also, if you
Pong is played with a paddle, a ball, a WIN sprite and
a red bar along the bottom of the background. The Ball want higher scores, you could increase the
bounces off the 3 sides of the stage or the player- ‘change score by’ for each touch of the Paddle
controlled Paddle. The player can only move the paddle with the Ball (e.g. by 5)
sideways. If the Ball touches the bottom red bar the Read the Advanced version note below for a
game is over. The player wins, if the timer reaches zero. more difficult version of the game
The Paddle is about 4 grid squares (80 pixels
SCRATCH for Your Kids © Seamus O’Neill 2021
when clicked This is script 1 of 2 in width and about 20px high. Make sure you
A headset is align the paddle’s Rotation point with the
There are 3 sprites. You
set score to 0 recommend. can get the Ball in the centre of the canvas.
Paddle Win Sprite library and make The WIN picture is made up from the
set y to 160
Get the Ball in the Ball
the Paddle and WIN
Sprite library sprites in the Paint Editor. Get the Blue Sky backdrop and
hedgehog sprite and letter sprites!
turn 20 degrees draw the red bar in the backdrop Editor.
There are two
scripts on This is script 2 of 2 on the Ball
when clicked There is only
go to front layer Ball the Ball
when clicked one script on
the Paddle
forever
forever Paddle
Why not code the collision set timer to 30 Ball Draw a Paddle
move 10 steps between Paddle and Ball by set y to -160 Set x to (mouse x) constrains
touching the color of the the Paddle horizontally.
repeat until timer 0
Paddle? It’s an option. set x to mouse x Set y: to -160 constrains it
if on edge, bounce
vertically to just above
wait 1 seconds the red bar.
if touching Paddle ? then
change timer by -1 Create your own WIN sprite
turn 180 degrees
Score 9
Script 1 of 2 Script 2 of 2 on
when clicked
on the Stage the stage creates
background music
set Score to 0
play sound Cave until done You can have several bats on the stage duplicate
It will fade out fully but you only have to code one. When export
change volume by -2
after 10 rounds. the bat is programmed you can make delete
duplicates. Code is copied in a duplicate.
59
THE FUN PALETTES Need Operators (Light Green)
Play Around with Play Around with the
What You Need to Know About
the Number Operators Basic Relational Operators
the four basic Maths operations ‘less than’ ‘equal to’ greater than’
1 a single operator plus
‘add’ ‘subtract’ ‘multiply’ ‘divide’
Type numbers less < 50 8 5 = 13 > 50
3 5 than 20 into the 6 3 6 3 6 3 6 3
plus operator. Click
to get its value. true true false
9 3 18 2
8 e.g. 5 + 3 = 8
‘addition’ ‘subtraction’ ‘multiplication’ ‘division’ These have a different shape and serve a different purpose.
‘plus’ ‘minus’ ‘times’ ‘divide by’ Read what’s on the block from left to right to compare the
2 a single operator in the say () block. ‘total’ ‘take away’ ‘by’ ‘into’*
value on the left of the sign with the value on the right. They
Each has a sign or symbol and vocabulary report only true or false. Think of the less than and greater
13
SCRATCH for Your Kids © Seamus O’Neill 2021
say 2 11
We can only manage two numbers at a time, than signs as like the jaws of a crocodile. Snapping jaws
one on the left of the sign and one on the making bigger bites. Crocodile jaws always face to the
Click to make the right. Even though there are no words we BIGGER number. The Croc’s body is always on the smaller
sprite say its value. read the expression from left to right. It’s OK side of its great jaws.
to switch around the plus and multiply smaller smaller
3 plus, subtract, multiply, divide numbers but NOT the subtract and divide greater
Use any single operator and get a value numbers. We usually write multiplication when this sprite clicked
with x as 2 x 5 and division with a dot above Input numbers
8 2 2
7 a dot (like a fraction) as 10 ÷ 2. Calculators, ask Click me and input a number and wait between
keyboards and computers use the ‘asterisk’ 0 and 20.
6 2
14 for multiplication and ‘slash’ for division. forever Which numbers report true
*NB: Be careful when you use the word ‘into’ and which report false?.
say 10 5
when reading division. Why? You switch say answer 11 The hexagon shape
around the sense and get a different value. slots into the round
Click to make the sprite say its value. So 10 ÷ 2 is NOT ‘10 into 2’ but ‘2 into 10’! say () input window.
4 combinations plus, subtract Thinking with the Operators You have 5 sweets left
plus inside
a minus
2 6 Six white eggs, 2 brown eggs and 3 of
them broken. Forget about eggs and See it at:
7 4 gives this 7 4 2 think only numbers https://scratch.mit.edu/projects/477516868
6 2 3
using Scratch.
Use the say () block also 9 say join join You have 8 3 2 4 sweets left.
5 (6+2)-3
5 combinations 1
5 3 7 I had some sweets. 8 were
say join join apple banana banana
16 chocolate and 3 were caramel. Jen
“(space) sweets left.”
took 2 sweets and Jan took 4. Forget
say 5 3 1
about sweets, chocolates, caramels. ( 8 + 3 ) - ( 2 + 4 ) “You have (space) ” 8 3 2 4
Make the sprite say its value. You do the thinking. Let Scratch do the Maths. Use a combination of text (string) and number data.
60