C39 · Topic 3.12 · 40 minutes · AAP-3.A
Arguments, parameters and calls
By the end you can:
- Match arguments by position.
- Create a fresh local trace for each call.
- Choose inputs that expose argument-order mistakes.
Before this lesson: topics 3.1, 3.6.
- Parameter
- A name in a procedure definition that receives an argument value.
- Argument
- A value supplied in a particular procedure call.
Understand
A procedure groups instructions under a name and may accept parameters. Arguments are supplied in a call and match parameters by position under the AP convention. Different names in the caller do not alter that ordering, so read the definition and call together rather than guessing from the argument variable names.
Each call uses its supplied values. Trace the parameter bindings before evaluating the body, especially when operations are not symmetric. Equal arguments or a commutative expression can conceal a swap; a good distinguishing test assigns different values to roles that produce different results when exchanged.
Worked example
quote(base,perItem,count)returns base+perItem*count.
PROCEDURE quote(base,perItem,count)
{ RETURN(base + perItem * count) }- quote(5,2,3)binds base 5,perItem 2,count 3.
- The expression gives 5+6=11.
- quote(2,5,3)instead gives 2+15=17, exposing a swap of the first two roles.
Explore each concept
Choose a concept, change its inputs and follow the explanation. Each example models the stated rule or scenario; completing it is practice rather than evidence of mastery.
- Argument binding and local calls
- RETURN ends the call
- DISPLAY is not a returned value
Change it · step through · explain
Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.
Ready · Make a prediction
- Argument (0–10)3Waiting
- Procedure bodyreturnWaiting
Ready to explore: Call, return, display and resume
Why: Change an input, predict the first effect, then advance one step.
Try this: Change one input or choose another listed case. Predict the effect, reset and compare the states and governing rule.
Step through and experiment
Change it · step through · explain
Change an input, predict what will happen, then advance one step. Read why the state changes, reset and experiment. This fixed teaching model does not save progress or award XP.
Ready · Make a prediction
- Input 15Waiting
- Input 22Waiting
- Input 33Waiting
Ready to experiment
Why: Predict the first change, then advance one step.
Try this: Change one input, predict the difference, then reset and compare.
Check a misconception
Claim: Argument variables match parameters by their names regardless of position.
Position determines the binding under this call convention.
Guided practice
Trace quote(4,3,2), naming every binding.
Work with a partner. Make a prediction, compare your reasoning, then identify the rule that supports your answer.
Independent transfer
Give a weak and a stronger test for swapping base and perItem.
Exit check
Why should you write bindings before the calculation?
Write your reasoning before comparing with a classmate. If your teacher assigned this task, submit it through My classes to save your work and receive feedback.
Check yourself
Your practice so far
Check an answer to see its rationale.