Programming Course for Beginners - ZedLX

The Easiest Online Computer Programming Course, for Free

Variables [1/14]


Variables

A variable is a name that can be associated to a value.

A variable must be introduced before it is used.

Variables are introduced by a statement of new variables. A statement of new variables begins with the symbol #.

Each variable must be of some type. In this example, the variable x is of type num. In other words, the first statement introduces the variable named x of type num, with initial value of 10.

The type num is used for numbers. Therefore, the variable x cannot be assigned anything but a number. For example, a string cannot be assigned to x.

The value of a variable can be changed. In this example, the variable x was equal to 10 at the start, but later its value was changed to 3.

Exercise

1. Change the name of variable x to i.
[Run the program]

Loading...