Variables in a computer
program
In computing, we use the
word variable to mean a specific part of
a computer that can store a piece of
information
that changes or varies when
the program is run.
•Variables can contain words, numbers
and like TRUE or FALSE.
A variable can use text as well as numbers.
In our quiz program, we can create and use a variable
called PLAYER NAME to store the player's name once they have typed it in.
Example : Player name = EMMANUEL
A variable is container that used to store
values.
Classify the following variables into TEXT,
BOOLEAN and NUMBER:
a. Score = Number
b. Age=Number
c. Name=TEXT
d. Gender =TEXT
e. Phone Number=Number
f. Colour=TEXT
g. Married = TRUE/FALSE
h. Address= TEXT
i. Watched_Moana? = FALSE
j. School fee =NUMBER
k. Year =TEXT
HOW VARIABLES WORK
Variables are a very useful programming tool. Here's
how variables work.
•A program can have more than one variable, but each one will
have its own name.
•A variable can only work with one piece of
changing information at a time.
•Variables can contain words, numbers
and values like TRUE or FALSE.
•Once information is collected in a variable, it can be used
somewhere else in the program.
HOW VARIABLES WORK
2-PLAYER GAME
Variables to be used are:
1. Player 1:TEXT
2. Player 2: TEXT
3. Score : NUMBER
4. Players_turn: TRUE OR FALSE
What is a variable in a computer program?
A. A place to store information that changes
B. A command that tells the program to stop
C. The name of the person who wrote the program
Which of these statements is true?
A.A variable can use numbers and words
B.A variable can only use words
C.A variable can only use numbers
When a new shopper gets to the
checkout, the screen display reads
£0.00.
When the shopkeeper get new items,
he/she
records them on the computer
Write out the variable types for
Price = NUMBER
New item = TEXT
Bought? = Boolean