PCEP-30-02 · Question #204
Which of the following items are present in the function header?
The correct answer is D. function name and parameter list. Option D is correct because a function header - the opening line of a function definition - contains exactly two components: the function name (which identifies and allows you to call the function) and the parameter list (which defines what inputs the function accepts)…
Question
Options
- Afunction name
- Breturn value
- Cparameter list
- Dfunction name and parameter list
How the community answered
(39 responses)- A10% (4)
- B5% (2)
- C3% (1)
- D82% (32)
Explanation
Option D is correct because a function header - the opening line of a function definition - contains exactly two components: the function name (which identifies and allows you to call the function) and the parameter list (which defines what inputs the function accepts), typically written as def greet(name, age): in Python.
Option A is wrong because the name alone is incomplete - without the parameter list, the function header is not well-formed. Option C is wrong for the same reason in reverse: a parameter list floating without a name has no identifier to call. Option B is the most common trap - the return value is produced by a return statement inside the function body, not declared in the header (unlike the return type in statically-typed languages like C or Java, which is a separate concept).
Memory tip: Think of the function header as a nameplate on a door - it tells you the room's name and what you need to bring in (parameters). What comes out of the room (the return value) is only revealed once you're inside.
Community Discussion
No community discussion yet for this question.