Page 108 - 2502_Pakistan-kifayat_C-6
P. 108
Iteration
Iteration is a programming construct that allows repeating a set of instructions Loop
multiple times. It is also called a loop. The program keeps running the instructions
until a certain condition is met or is no longer true.
Iteration is useful when you want to perform repetitive tasks efficiently without
writing the same code again and again. For example, counting from 1 to 10 or
processing items in a list.
PROGRAMMING CONSTRUCTS IN SCRATCH
Programming Constructs in Scratch are the basic building blocks that help you create scripts (code) to
make your sprites perform actions. In Scratch, these constructs are represented by blocks that you drag
and connect. The main programming constructs in Scratch are: Sequences, Events, Loops, Conditional
Statements and Variables.
Sequence
Sequence means placing blocks one after another so that the sprite performs actions step-by-step in
the order you arranged them.
For example:
block lets the sprite move forward (in the direction it is facing) by the number of steps
given in the text box in the block. It is found under the Motion category.
block lets the sprite turn in a clockwise direction by the given degrees.
block adds a speech bubble to the sprite with the given text.
Event
Events are special blocks that start your script when something happens. They tell the program when
to begin running a set of instructions.
Common event blocks include:
block activates the script attached to this block when the Green flag or Go button is
clicked.
block activates the script when the chosen key is pressed.
block activates the script attached to this block when you click the sprite.
106 Premium Edition-VI

