by David J. Malan <malan@post.harvard.edu>
Printer-Friendly Version of Tutorial

« Previous | Table of Contents | Next »

Variables

In programming, a variable is a placeholder for some value, much like x and y are popular variables in algebra. In Scratch, variables are represented with blocks shaped like elongated circles, uniquely labeled by you. Variables, generally speaking, can be local or global. In Scratch, a local variable can be used by just one sprite; a global variable can be used by all of your sprites.

Variables allow us, for instance, to instruct a sprite to count up from 1:



A variable that only takes on a value of true (i.e., 1) or false (i.e., 0), incidentally, is called a Boolean variable.

With statements, Boolean expressions, conditions, loops, and variables now under your belt as building blocks, we can now explore two higher-level programming constructs, starting with threads.

« Previous | Table of Contents | Next »