What are Integer Variables?
Jon Mattingly avatar
Written by Jon Mattingly
Updated over a week ago

Variables store information in a program. You can think of variables like a box or a container with a name on them, related to the things inside. These items inside are called values, which can be stored as text or numbers. When you use a variable in a program you’re able to control the output of the program, or what a user sees. Learners are first introduced to integer variables in Game Designer.

There are many different types of values that can be stored in a variable. In Kodable, we focus on three: Strings, Integers, and Arrays.

An integer is a type of value that can be stored in a variable. Integers are whole numbers that can be positive, negative, or zero.

Definition: Integers are values written and stored as numbers and are often called “ints”. Integers are used to store values and run loops.

In Real Life: A real life example of an integer is a person’s age: Think of a person as a variable here. Age is a value associated with a person, just like a name is, but since age is a number we use numbers instead of words in our code. Variables can change, just like a person’s age increases by one each year.

In programming: In programming, integers are used to do 2 things: store values and run loops.

In Kodable, learners practice storing integer values using numbered fuzzballs: Learners will put a number in the command bin that matches a value to the variable. Assigning matching values will clear the asteroid field when the integer is launched at the field.

In this lesson, my ship variable contains an integer and is going to apply that value to the asteroid. If the value matches, the asteroid will disappear.

Students need to think critically about how to clear the asteroid field in as few moves as possible. 

Why We Use Ints: Integers make it easy for programmers to reuse the values in their programs. Integers allow us to run loops by telling the computer how many times to repeat certain tasks. This makes it easier to carry out complex processes and do more in our programs.

Did this answer your question?