What is a Variable? Select a name for your variable/container from the list. (Try all of them!)

In this example, we are using a User-Defined variable to store a word that represents the user's choice of a beverage. The glass represents the named variable/container, drinkChoice.

drinkChoice

contains

<word>

VARIABLE NAME

VARIABLE VALUE

water

tea

tea

punch

beer

Click on one of the drink choices to fill the glass and watch what happens to the drinkChoice variable value below.

A variable can be used to tally a count of something. In this case, we're using the User-Defined Egg_Count variable to keep track of how many eggs are in the basket.

Egg_Count

contains

<num>

egg(s)

VARIABLE NAME

VARIABLE VALUE

Drag and drop the eggs into and out of the Egg_Count basket and watch what happens to the variable value below.

Sometimes you want to use a variable as a sort of flag or switch to tell you if some condition is currently true or false. The value of it should always be one of two values, such as [true or false], [yes or no], [open or closed], or in the case of this example, [on or off]. So the User-Defined variable, light_switch, is initialized with the value "off".

Click the light switch a few times and watch what happens to the light_switch variable value below.

light_switch

contains

off

VARIABLE NAME

VARIABLE VALUE

light_switch