A variable holds one value. A list holds many, in order, under a single name — every score in a game, every name in a class. On List Lane, Year 4 coders find items by position and change lists step by step.
Apa yang akan dipelajari anak anda
- Know that a list stores many items in order under one name
- Find an item by its position, and say how long a list is
- Add, delete, insert and replace items
- Understand that a loop can do something to every item in a list
Position matters
Each item has a position. In these quests, as in Scratch, the first item is item 1. Many text languages count from 0 instead — a famous source of bugs, and worth knowing about.
Lists and loops
Lists and loops are best friends. “For each item in the list, say the item” works whether the list has three items or three thousand. That is why programmers reach for a list instead of lots of separate variables.
Contoh soalan
Berikut ialah beberapa soalan seperti dalam misi pertama. Bolehkah anda menjawabnya?
1. A list holds: apple, banana, cherry. What is item 3?
- banana
- cherry
- There is no item 3
- apple
Tunjuk jawapan
Jawapan: cherry. Counting along, the third item is cherry.
2. A list holds: sun, moon, star. Which item is “moon”?
- Item 3
- Item 1
- Item 2
- Item 4
Tunjuk jawapan
Jawapan: Item 2. Moon is second in the list.
3. A shopping list holds: milk, eggs, bread. Does it contain “eggs”?
- No
- Yes
Tunjuk jawapan
Jawapan: Yes. Eggs is the second item in the list.
4. fruits = [apple, banana, cherry]. Match each index to its item.
- fruits[2]
- fruits[0]
- fruits[1]
- apple
- cherry
- banana
Tunjuk jawapan
Jawapan: fruits[0] → apple · fruits[1] → banana · fruits[2] → cherry. Most programming languages count list positions from 0.
Tip untuk orang dewasa
- Write a real list — shopping, favourite films — and number the items.
- Play “list commands”: add to the end, delete item 2, insert at position 1.
- In Scratch, make a list and try the add, delete and insert blocks.