Foundations-of-Computer-Science practice question 1 of 15

What is the purpose of a parameter in a function definition?

Full set: 71 questions
Answer options
A:

A. To describe the values that can be passed into the function

Correct answer
B:

B. To stop the function from ever running

C:

C. To force all outputs to be integers

D:

D. To save the function to disk automatically

Correct Answer:
A. A. To describe the values that can be passed into the function
Explanation

A parameter is a variable declared in a function's definition that acts as a placeholder for data that will be passed to the function when it is called. Parameters define the function's interface, specifying the number and types of values it expects to receive as input. When the function is invoked, the values passed to it, known as arguments, are assigned to the corresponding parameters, allowing the function to operate on that specific data.

Why Incorrect

B. Parameters are necessary for a function to receive data and run; they do not prevent its execution.
C. A function's return type, not its parameters, determines the data type of the value it outputs.
D. Saving a function is a file system operation managed by the programmer or IDE, not a function of its parameters.

References

1. Abelson, H., & Sussman, G. J. (1996). Structure and Interpretation of Computer Programs (2nd ed.). MIT Press. Section 1.1.5, "The Substitution Model for Procedure Application," explains that to apply a procedure, you substitute the formal parameters with the arguments.

2. Guttag, J. V. (2013). Introduction to Computation and Programming Using Python (Rev. and expanded ed.). MIT Press. Chapter 4, "Functions, Scoping, and Abstraction," defines a function's parameters as the variables that are bound to the arguments of the function call.

3. Stanford University. (n.d.). CS106A Course Materials. "Functions." The course reader explains that parameters are the variables in the function's parentheses that hold the values passed in by the caller.

Scroll to Top