Log in from a computer to take this course

You'll need to log in from a computer to start CS101 Livestream Series. But you can practice or keep up your coding streak with the Codecademy Go app. Download the app to get started.

apple storegoogle store

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


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.

Sign up to start coding

Mini Info Outline Icon
By signing up for Codecademy, you agree to Codecademy's Terms of Service & Privacy Policy.

Or sign up using:

Already have an account?