Free practice · ordering · medium

Practice

Trace a function call

Order the execution of a call to double(6) where double defines result = number * 2 and returns result.

Python hand trace

Follow the statements that execute, one state change at a time

  1. InputsRecord initial values
  2. PathFollow indentation and branches
  3. StateRecord each assignment
  4. CallsBind arguments and trace returns
  5. OutputState the final observed value
  6. CheckRepeat the trace independently

A reliable prediction starts with inputs, respects indentation and control flow, records assignments, and separates returned values from printed output.

Arrange in the correct order
  1. 1. Give 12 back to the calling statement
  2. 2. Return result from the function
  3. 3. Calculate result = number * 2
  4. 4. Bind 6 to the parameter number