PCAP-31-03 practice question 6 of 25
Select the valid fun () invocations: (select two answers) def fun (a, b=0): return a*b
Full set: 147 questionsfun() requires one positional argument a and has an optional keyword/positional argument b with default 0. Calling fun(a=0) supplies a via keyword; calling fun(1) supplies a positionally, letting b default. Both invocations therefore match the defined signature.
A. Supplies b without a; Python raises TypeError: missing required positional argument ‘a’.
C. Places a positional argument (0) after keyword argument b, violating call syntax; SyntaxError.
1. Python 3 Language Reference, §6.7 “Calls” – rule that positional arguments must precede keyword arguments (docs.python.org/3/reference/expressions.html#calls)
2. Python 3 Tutorial, §4.7.1 “Default Argument Values” – example with required and defaulted parameters (docs.python.org/3/tutorial/controlflow.html#default-argument-values)
Keep practicing
Take the free PCAP-31-03 practice test
Ten exam-style questions with answers and explanations, plus the exam facts and study guides.
More questions
Other PCAP-31-03 practice questions
- Question 3How many elements will the list2 list contain after execution of the following snippet? l…
- Question 7Is it possible to safely check if a class object has a certain attribute0
- Question 10Which of the equations are True? (Select two answers)
- Question 13Which of the following lambda function definitions are correct? (Select two answers)
- Question 15Which of the following invocations are valid? (Select two answers)
- Question 16Which of the following words can be used as a variable name? (Select two valid names)
