🔠 Variables | myBetabox

🔠 Variables

Play Me!

Did you guess her number?

Variables are an incredibly important part of computer science! They allow us to store any kind of data we want, and use it again later.

Let’s think of some examples.

  • In many games, you do things to earn points and increase your score. That score is a variable, and is increased (or decreased) depending on what you do in the game. In the hedgehog mini game on the next page, we will have a score variable.
  • Just like with scores, numbers can be stored as variables for values.
  • Maybe in other games, you have to enter your name at the very beginning. Then, in the future, other characters in the game can call you by that name. Here, your name is a variable.

In your stories, maybe you’ll want to ask for your viewer’s name so you can use it later. That could look something like this, where we ask for the user’s name, and save it to a variable called user_name.

The code for that looks like this:

Your Turn!

Follow along with this video to create stored variables!