Variables hold data
Answers are for parents and teachers.
1
Choose four things in your home and describe each one as a variable. Write a name, a value and a data type, for example: pencilsInCup, 5, integer.
Answers vary. Each variable needs a clear name, a value and the right data type: integer for counts, string for words, character for one letter.
2
What is the data type of each? (a) 1200, (b) tiger, (c) M, (d) hello world, (e) 0.
(a) integer, (b) string, (c) character, (d) string, (e) integer.
3
Draw a flowchart that asks for your favourite colour, stores it in a variable called favColour and says Nice choice and the colour.
Start, ask: what is your favourite colour?, set favColour to the answer, say Nice choice and favColour, stop.
4
Write a trace table for: set a to 6, set b to 4, set c to a − b, change a by 2.
First a = 6, then b = 4, then c = 6 − 4 = 2, and then a changes to 6 + 2 = 8. The final values are a = 8, b = 4 and c = 2.
5
Explain to a family member the difference between set and change by, using a jar of coins as an example.
Set puts a new amount in the jar, whatever was there before. Change by adds to the amount already in the jar, or takes away if the number is negative.