Computer Science Course of Study (WA)

 

Variables

Page history last edited by Mike Leishman 1 yr ago

Variables

Scratch dosn't provide much in the way of data types for variable; in fact, there is only one data type and that can be an integer or a real value.

 

 

In the example below, the score for the game is initialised (set to 0) and then when a condition arises, the value of the score is increased.

 

 

Other places that these variables can be used are in parametres for sensing statements.

 

 

Exercises

1 Write a program using a variable that is used as a switch - a value of 0 indicates that the state is off and a value of 1 indicates that the state is on. Use it to turn an animation off.

 

2 Modify the program created in (1) to allow and animation to be turned on and off.

 

3

 

Comments (0)

You don't have permission to comment on this page.