The_Official_Raspberry_Pi_-_Beginner’s_Book_Vol1,_2018 (1)

(singke) #1

(^68) THE OFFICIAL RASPBERRY PI BEGINNER'S GUIDE
when clicked
set loops to^0
repeat until loops =^10
say loops for^2 secs
if > then
say Hello! for^2 secs
change loops by^1
The if then block is a conditional block, which means the blocks inside it will only run if
a certain condition is met. Click on the Data category of the blocks palette, drag and drop
the loops reporter block into the first empty square in your n > n block, then click on
the second empty square and type the number ‘5’. Finally, click on the word ‘Hello!’ in your
say Hello! for 2 secs block and type ‘That’s high!’.
when clicked
set loops to^0
repeat until loops =^10
say loops for^2 secs
if loops >^5 then
say That's high! for^2 secs
change loops by^1

Free download pdf