Learn
Variables
Introduction to Variables

In programming, we have a way of storing values so that we can reuse them throughout our program or change them, if necessary. This concept is known as a variable.

Maybe you’re familiar with the math term variable, or the word variability. Programming variables share qualities with each. Similar to a variable in math, a variable is a way of saving a piece of information with a specific name. By giving a value a name, we can easily reuse that value over and over again in our code. Like the idea of variability, a programming variable allows us to easily change a value throughout our code.

Variables are an important first step in coding because with variables we can start using an important programming tool: repetition. Rather than writing out a piece of data every time we need it, we write it out once and the computer remembers it and can repeat that information back.

In this lesson, we’ll explore why variables are an important part of programming, including:

• Using variables to reuse a value
• Using variables to change a value

### Instructions

Imagine that you’re building a game using tiles with different patterns, representing different terrains.

The tiles need to be placed in the following order:

First row:

• grass
• rocks
• grass

Second row:

• forest
• rocks
• forest

Third row:

• rocks
• grass
• rocks

In each box, enter the type of terrain that should go in the accompanying tile. Continue until the entire board is filled.