wayground logo

Free Printable Worksheets

NEW

Font size

S
M
L
XL
Worksheets

Understanding Variables in Programming

Total questions: 15

Worksheet time: 8mins

Name
Class
Date
1.

What do computer applications (apps) use to keep track of information that changes and updates?

a)

Fixed data

b)

Computer memory

c)

Static files

d)

User input only

2.

In programming, what is a variable?

a)

A fixed number that never changes

b)

A container for storing a value

c)

A type of computer hardware

d)

A command to stop the program

3.

In a game, 'score' and 'lives' are examples of what?

a)

Fixed constants

b)

Program commands

c)

Variables

d)

Game levels

4.

What keyword is used to create a new variable in many programming languages?

a)

new

b)

let

c)

var

d)

create

5.

When creating a variable, what should you choose for its label?

a)

Any random word

b)

A word that describes the variable's purpose

c)

A number

d)

A special symbol

6.

How do you assign a value to a variable after it has been created?

a)

Using the plus sign (+)

b)

Using the minus sign (-)

c)

Using the equal sign (=)

d)

Using the multiplication sign (*)

7.

When should the 'var' keyword be used in programming?

a)

Every time you refer to a variable

b)

Only when creating a new variable

c)

Only when assigning a value to a variable

d)

Never, it's an old keyword

8.

Which of these is the correct way to assign the value 5 to a variable named 'points'?

a)

5 = points;

b)

points = 5;

c)

points + 5;

d)

var 5 = points;

9.

What does it mean to 'initialize' a variable?

a)

To delete a variable from memory

b)

To create a variable and assign it a value at the same time

c)

To change the name of a variable

d)

To print the variable's value to the screen

10.

In programming, what is the equal sign (=) often called, and what does it mean?

a)

Equality operator; it means both sides are mathematically the same.

b)

Assignment operator; it means "gets the value."

c)

Comparison operator; it checks if two values are equal.

d)

Arithmetic operator; it performs addition.

11.

Which of the following best describes the purpose of a variable in a program?

a)

To display graphics

b)

To store changing information

c)

To connect to the internet

d)

To run the program faster

12.

What happens if you try to use a variable before it has been created?

a)

An error will occur

b)

The variable will be automatically created

c)

The program will run normally

d)

The variable will have a value of zero

13.

Which of these is NOT a good name for a variable that stores a player's score?

a)

playerScore

b)

score

c)

points

d)

123score

14.

Why are variables useful when programming?

a)

They make the code run faster.

b)

They allow you to store and manipulate data.

c)

They are used to decorate the code.

d)

They help in creating graphics.

15.

Why are meaningful variable names important?

a)

They make the code look colourful.

b)

They help in understanding the purpose of the variable.

c)

They make the code run slower.

d)

They are required by the computer to execute the code.