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 4Input
Call doublePlusOne with x = 4.
Choose Play to advance steps automatically.
Read or choose any step
- Input
Call doublePlusOne with x = 4.
- Double
Calculate 2 × 4 = 8.
- Add
Calculate 8 + 1 = 9.
- Return
Return 9 to the caller.
TRY BEFORE CHECKING
Exercises with feedback
MAKE SOMETHING YOU CAN EXPLAIN
Your practical challenge
Write pseudocode and test the function with 0, 4 and 7. Show expected results first.
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.