Which of the following lines correctly invoke the function defined below:
def fun(a, b, c=0):
# Body of the function.
(Select two answers)
A . fun(0, 1, 2)
B. fun(b=0, a=0)
C. fun(b=1)
D. fun()
Answer: A,B
Explanation:
Topics: functions positional parameters keyword parameters
Try it yourself:
def fun(a, b, c=0):
# Body of the function.
pass
fun(b=0, a=0)
fun(0, 1, 2)
# fun() # TypeError: fun() missing 2 required
# positional arguments: ‘a’ and ‘b’
# fun(b=1) # TypeError: fun() missing 1 required
# positional argument: ‘a’
Only the parameter c has a default value.
Therefore you need at least two arguments.
Latest PCEP-30-02 Dumps Valid Version with 124 Q&As
Latest And Valid Q&A | Instant Download | Once Fail, Full Refund