A variable is a box with a name on it that holds a number. A game uses variables to remember your score, your lives and how many coins you have. Year 1 coders read tiny programs that put a number in a box and then change it.
Apa yang akan dipelajari anak anda
- Know that a variable has a name and holds a value
- Understand that “set” puts a new number in the box
- Understand that “change by” makes the number go up or down
- Follow a short program step by step to find the final value
Set, then change
“Set score to 2” puts 2 in the box called score. “Change score by 1” adds 1, so the box now holds 3. “Change score by −1” takes 1 away. The box only ever holds one number: the newest one.
Read it like a robot
Computers follow a program one line at a time, from the top. To find the answer, do the same: say the number after every line, and don’t skip ahead.
Contoh soalan
Berikut ialah beberapa soalan seperti dalam misi pertama. Bolehkah anda menjawabnya?
1. What is apples at the end?
- 4
- 1
- 5
- 6
Tunjuk jawapan
Jawapan: 5. apples starts at 1. 1 + 4 = 5. So apples ends at 5.
2. What is coins at the end?
Tunjuk jawapan
Jawapan: 1. coins starts at 0. 0 + 1 = 1. So coins ends at 1.
3. What is apples at the end?
Tunjuk jawapan
Jawapan: 4. apples starts at 2. 2 + 2 = 4. So apples ends at 4.
Tip untuk orang dewasa
- Use a real box and some blocks: “set” means empty it and put that many in, “change” means add or take away.
- Keep score in a game together and say “change score by 1” for every point.
- Ask “What is in the box now?” after each step.