June 2010
Beginner
210 pages
3h 45m
English
A variable stores a value in memory so that it can be used later in a program. The variable can be used many times within a single program, and the value is easily changed while the program is running.
The primary reason we use variables is to avoid repeating ourselves in the code. If you are typing the same number more than once, consider making it into a variable to make your code more general and easier to update.
For instance, when you make the y-coordinate and diameter for the two circles in this example into variables, the same values are used for each ellipse:

size(480,120);smooth();
Read now
Unlock full access