NOTE: Learn more about integers and other concepts on your teacher dashboard. Each unit has an overview that explains the concept in detail. https://dashboard.kodable.com/#/curriculum/6
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.
There are different types of variables that are used in different situations: strings, integers, and arrays. There are different types of variables that are used in different situations: strings, integers, and arrays. We’re going to talk about integers, which 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 was, 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.
We talked about how students practice strings during their independent practice lessons. Students will apply integers the same way: Students 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. In this level, I match my integer value with the value in the center of the asteroid field, and the remaining like-values touch and clear themselves.
In programming, Ints are used to store values in a program and run loops.
Let’s talk about how Ints are used to store values by revisiting our video game example that we used for string variables. Storing a character’s name, hair color, or eye color are all examples of string variables. But what about how big a character is, how long their hair is, or how many eyes they have? These are number values, so we use Ints to tell the computer what the character should look like when the player sees it on the screen.
We use integers in programming when we run loops too- remember our peanut butter jelly making example where we talked about making 500 peanut butter and jelly sandwiches for a school field trip? The number of times we tell a computer to repeat a process or run a loop, is stored as an integer.
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.