Practice question · Sort into groups
For def scale(factor): return factor * 10, later called as scale(60), sort each item by what it is.
Groups: Parameter · Argument · Return value
- 600, handed back to the caller
- factor, named in the definition
- 60, supplied in the call
Hints
- A parameter is a name in the definition; an argument is an actual value in the call.
- The value handed back by return is neither of those two.
Show the answer
Parameter: factor, named in the definition
Argument: 60, supplied in the call
Return value: 600, handed back to the caller
Why
factor is the parameter (a name in the definition), 60 is the argument (the actual value passed), and 600 = 60 * 10 is the return value. Confusing parameters with arguments is the pitfall named in this lesson: the definition declares names, the call supplies values.
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…
- Match each term to its meaning.
- 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.