NEW
Font size
WorksheetsUnderstanding Variables in Programming
Total questions: 15
Worksheet time: 8mins
What do computer applications (apps) use to keep track of information that changes and updates?
Fixed data
Computer memory
Static files
User input only
In programming, what is a variable?
A fixed number that never changes
A container for storing a value
A type of computer hardware
A command to stop the program
In a game, 'score' and 'lives' are examples of what?
Fixed constants
Program commands
Variables
Game levels
What keyword is used to create a new variable in many programming languages?
new
let
var
create
When creating a variable, what should you choose for its label?
Any random word
A word that describes the variable's purpose
A number
A special symbol
How do you assign a value to a variable after it has been created?
Using the plus sign (+)
Using the minus sign (-)
Using the equal sign (=)
Using the multiplication sign (*)
When should the 'var' keyword be used in programming?
Every time you refer to a variable
Only when creating a new variable
Only when assigning a value to a variable
Never, it's an old keyword
Which of these is the correct way to assign the value 5 to a variable named 'points'?
5 = points;
points = 5;
points + 5;
var 5 = points;
What does it mean to 'initialize' a variable?
To delete a variable from memory
To create a variable and assign it a value at the same time
To change the name of a variable
To print the variable's value to the screen
In programming, what is the equal sign (=) often called, and what does it mean?
Equality operator; it means both sides are mathematically the same.
Assignment operator; it means "gets the value."
Comparison operator; it checks if two values are equal.
Arithmetic operator; it performs addition.
Which of the following best describes the purpose of a variable in a program?
To display graphics
To store changing information
To connect to the internet
To run the program faster
What happens if you try to use a variable before it has been created?
An error will occur
The variable will be automatically created
The program will run normally
The variable will have a value of zero
Which of these is NOT a good name for a variable that stores a player's score?
playerScore
score
points
123score
Why are variables useful when programming?
They make the code run faster.
They allow you to store and manipulate data.
They are used to decorate the code.
They help in creating graphics.
Why are meaningful variable names important?
They make the code look colourful.
They help in understanding the purpose of the variable.
They make the code run slower.
They are required by the computer to execute the code.
