HelioLearnSkills for every stage

GRADE 7 · COMPUTATIONAL THINKING · ABOUT 45 MINUTES

Trace a function

Separate input, transformation and returned output.

Understand the idea

A function can name a reusable transformation. A returned value is the result passed back to the caller.

WORKED EXAMPLE

Let doublePlusOne(x) return 2x + 1. With input 4, double to 8, add 1 and return 9.

Watch it step by step

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

Input

Call doublePlusOne with x = 4.

Choose Play to advance steps automatically.

Read or choose any step
  1. Input

    Call doublePlusOne with x = 4.

  2. Double

    Calculate 2 × 4 = 8.

  3. Add

    Calculate 8 + 1 = 9.

  4. Return

    Return 9 to the caller.

TRY BEFORE CHECKING

Exercises with feedback

Enable JavaScript for feedback, or use the printed exercises.

MAKE SOMETHING YOU CAN EXPLAIN

Your practical challenge

Write pseudocode and test the function with 0, 4 and 7. Show expected results first.

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

Describe an inverse transformation for a valid output.

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: Compare independent evidence →All six experiences