Lists: Many Values Under One Name · seed 1 · A4, ink-friendly. The answer key prints on its own page for grown-ups.

Many values, one name

Computing · Programming · ages 15-16
Name ______________________   Date ____________
  1. rainbowColours holds red, orange, yellow, green, blue, indigo and violet. What does rainbowColours[0] give?

    • orange
    • red
    • violet
  2. What is a list?

    • One value stored under many names
    • A name with no values at all
    • Many values stored under one name
  3. Appending adds the new item to the end of the list.

    Circle one:   True   False

  4. An empty chore list gets Wash the dishes, Do laundry, then Mow the lawn pushed on. What seat does Mow the lawn take?

    Answer: ______________

  5. After rainbowColours[4] = cyan, what sits in seat 4?

    • cyan
    • blue
    • violet
  6. Why does one list beat twenty separate variables for the same scores?

    • Twenty names run faster
    • One name holds them all, so the set stays tidy
    • Variables cannot hold numbers
  7. You insert a new item at the start of a list. What happens to the other seats?

    • Each old item shifts one seat up
    • Every seat keeps its old number
    • Only the last item moves
  8. A program reads slot 7 of a 7-item list and fails. What is the mistake?

    • The list needs one more push first
    • Slot 7 is invisible until printed
    • Seats run 0 to 6, so slot 7 is past the end
LightMySky · lightmysky.comW1-mt_ipB6kmyK85-s1

Answer key

For grown-ups. Fold this page away before handing over the rest.

Many values, one name W1-mt_ipB6kmyK85-s1

  1. red · Seat 0 holds the first colour, which is red.
  2. Many values stored under one name · A list bundles a whole collection under a single name.
  3. True · Append grows the end, so the newcomer takes the next free seat.
  4. 2 · Three pushes fill seats 0, 1 and 2 in order.
  5. cyan · Assignment rewrites that slot, so seat 4 now holds cyan.
  6. One name holds them all, so the set stays tidy · A single name keeps the whole set together with zero clutter.
  7. Each old item shifts one seat up · Squeezing one in at the front pushes each older item one seat along.
  8. Seats run 0 to 6, so slot 7 is past the end · Seven items fill seats 0 to 6. Reaching for 7 is one too far.
Worksheet · LightMySky