Practice question · Match the pairs
Match each term to its meaning.
- Parameter
- Argument
- Return
- Local variable
- A name listed in the function's definition
- Ends the function and hands a result back
- The actual value passed in a call
- Exists only during the call, invisible outside
Hints
- Two of these are about the inputs of a function; two are about what happens inside or on exit.
- One term names a value that vanishes the moment the function returns.
Show the answer
- Parameter → A name listed in the function's definition
- Argument → The actual value passed in a call
- Return → Ends the function and hands a result back
- Local variable → Exists only during the call, invisible outside
Why
Parameters are the definition's names, arguments are the call's values, return both ends the function and yields a result, and a local variable lives only for the duration of the call. Expecting to read a local from outside the function is the second pitfall this lesson names.
Practise Functions and Parameter Passing
The app has 5 more questions on this lesson, and keeps your place in the course. Computer Science I is free to start.
More questions on Functions and Parameter Passing
- Whether a function can modify its caller's argument depends on whether the argument is mutable, not on how it…
- For def scale(factor): return factor * 10, later called as scale(60), sort each item by what it is.
- A function with a default argument def f(x, items=[]) behaves strangely: the list keeps its contents between…
- Order what happens when the call y = sq(2 + 3) runs, where def sq(n): return n * n.
- Select every statement about scope that is true.