Classroom Notes: 1.1 Assigning Variables
1) What is a variable in a computer program?
A variable is a named storage container in a program or algorithm
that holds data (a value) that can change while the program is
running.
2) What is a value? Give two examples of different types of
values.
A value is the actual data stored inside a variable. Values can
be:
- Numbers: e.g., 8, 15, 180
- Text/Words: e.g., "Miah", "apple"
3) What does the term "temporary" mean when referring to a
variable?
It means that the value stored inside a variable is not kept
forever; it can be changed or updated as the algorithm runs.
4) Why is it important to use meaningful variable names for a
variable?
A meaningful variable name gives clear information about the data
stored inside it. This makes it easier for us to understand what
the variable is used for.
5) Give an example of a good variable name and a poor variable
name for storing a player's score.
Meaningful Name: Score or PlayerScore
Poor Name: X OR Y
Poor Name: X OR Y
6) What is variable assignment?
Variable assignment is the specific action of giving a value to a
variable to store.
Example: set Age to 9
Example: set Age to 9
7) How many items of data can a single variable store at one time?
A variable can only store one item of data at a time.