HelioLearnSkills for every stage

GRADE 8 · COMPUTATIONAL THINKING · ABOUT 45 MINUTES

Accumulate a list total

Trace a loop that updates an accumulator.

Understand the idea

An accumulator stores a running result. Initialise it before the loop, then update it once per item.

WORKED EXAMPLE

Start total = 0. For values 2, 4, 6, add each once: totals 0, 2, 6, 12.

Watch it step by step

Step 1 of 4
TRACE THE STATE · READ THE EXPLANATION BELOWStep 10Step 2…Step 3…Step 4…Each state follows the specific rule in this workedexample.

Initialise

total = 0.

Choose Play to advance steps automatically.

Read or choose any step
  1. Initialise

    total = 0.

  2. Item 1

    Add 2; total = 2.

  3. Item 2

    Add 4; total = 6.

  4. Item 3

    Add 6; total = 12.

TRY BEFORE CHECKING

Exercises with feedback

Enable JavaScript for feedback, or use the printed exercises.

MAKE SOMETHING YOU CAN EXPLAIN

Your practical challenge

Make a trace table for the list and for an empty list. Explain the initial value.

Review your evidence

These ticks are your self-review. They do not automatically assess project quality. Ask an adult or partner to review what you can show.

Use the skill in a new situation

Adapt the trace to count only values above 3.

Choose a different space for another learner on this browser.

Notes and checks use this browser, separate from school sign-in.

Each space keeps each grade separate. These spaces are not private accounts; use separate browser profiles for privacy on a shared device. About your practice data

Next: Minimise data in a form →All six experiences