Curriculum
Course: Beginner: Algorithms & Coding
Login
Text lesson

Introduction to number variables and Join Operator

A number variable is like a special box that holds numbers. Just like text variables hold words, number variables store numeric values such as your age, height, or how many points you have in a game.
Creating a Number Variable

In Scratch, click on the “variables” section on the left.

Then, click “Make a Variable” and select “For all sprites.”.

Name the variable something like “Age”, “score,” or “points.”.

Naming a Number Variable

You can give your number variable any name that tells you what it stores. For example:

“Age” stores how old you are.

“Points” stores how many points you earned.

“Height” stores your height in meters or centimeters.

Deleting a Number Variable

If you no longer need a number variable, right-click on the variable’s name in the “Variables” section and choose “Delete Variable”.

Store User Input into a Number Variable

To store a number, you’ll use the “Set [variable] to []” block in Variables.

For example, if you’re asking someone’s age, you can store the response in the age variable.

Output the Value of a Number Variable

To show the value of the number, you can use the “Say [] for [] seconds” block, or you can use the “Show Variable [Variable]” block to show the variable’s value on the screen.

REAL EXAMPLE

Starting with Age Variables
Image

After Adding Height Variable

Image

After adding Score variable
Image

After adding Time variable

Image

You can also watch this video Number Variables

 

Join Operator in Scratch!

The Join operator in Scratch is used to combine (join) two pieces of text together to create one longer string. It’s like putting two words or sentences together to make a new one!

How does it work?

  • Join takes two inputs (pieces of text) and joins them into one.
  • Example:
    • “Hello” + “World” = “Hello World”
    • You can use it to join a name and surname or add a greeting with a name.

Using the Join Block in Scratch

1️⃣ Go to the Operators section.
2️⃣ Drag the Join block onto the script area.
3️⃣ Insert Text into the two parts of the block.
4️⃣ You can use variables or simple words!

join

Then now drag the say hello block from the Looks and replace “hello” with the join

join replace