You are on page 1of 10

Scratch Syntax: Part 1

Algebra-Geometry
Statements
 In programming, a statement is simply a
directive that tells the computer to do
something. Think of it as a command or an
instruction.
 In Scratch, any block whose label reads like a
command is a statement.
Boolean Expressions
 Sometimes, you only want a statement to be
executed under certain conditions. Such
conditions are defined in terms of Boolean
expressions.
 In programming, a Boolean expression is
an expression that is either true or false. In
Scratch, any block shaped like an elongated
diamond is a Boolean expression.
Boolean Expressions
 One such block is:

After all, it is either true that the mouse button


is down or it is false.
 Another such block is:
After all, it is either true that some number is
less than another number or it is false.
 With Boolean expressions can we construct
conditions.
Conditions
 In programming, a condition is something
that must be true in order for something to
happen.
 A condition is thus said to "evaluate to true" or
"evaluate to false."
 In Scratch, any block whose label says "if,"
"when," or "until" is a sort of conditional
construct.
Conditions
 IfConstruct: Instruct a sprite to say hello
only if, say, the user has depressed the
mouse button:

 If-Else Construct: Instruct a sprite to say


hello or goodbye, depending on whether the
user has depressed the mouse button:
Conditions
 WhenConstruct: Instruct a sprite to do
something when an event occurs:

 When Construct: Instruct a sprite to wait to


do something until a condition is true:
Loops
 In programming, a loop can induce multiple
executions of statements.
 In Scratch, any block whose label begins with
"forever" or "repeat" is a looping construct.
Follow Me

Follow Me applet
Homework
 Complete the Cat Walk Project
 You may wish to use the Scratch Reference
Guide and the Programming Concepts
Handout as resources
 Completed projects need to be submitted via
Interact by the due date.

You might also like