Exam PCAP All QuestionsBrowse all questions from this exam
Question 22

Select the valid fun () invocations:

(Choose two.)

    Correct Answer: B, D

    The function `fun` has one mandatory parameter `a` and one optional parameter `b` with a default value of 0. This means it is valid to call the function with one argument because `b` will automatically take the default value. Option B is valid because it provides a value for `a` while using the default value for `b`. Option D is also valid because it provides a positional argument that will be interpreted as `a`, with `b` taking the default value of 0. Conversely, Option A is invalid because it attempts to call the function using only the optional parameter `b` without providing a value for the mandatory parameter `a`. Option C is invalid due to incorrect syntax; positional arguments cannot come after keyword arguments.

Discussion
Monika23Options: BD

b is an optional parameter so the answer is B and D

N9Options: BD

b is an optional parameter so the answer is B and D

macxszOptions: BD

B. fun (a=0) D. fun (1)

diazed

Those are the correct answers

4a348e6

A is not the correct answer since it needs a or it needs a and b. In A it only shows b which is not applicable to the machine

4a348e6Options: BD

You would think it's C but it's not. This is becuase c has a syntax error of writing the b first and then a which is not the order.

TheFivePipsOptions: BD

The only hangup I had was on option C so here is an explanation for people like me: C attempts to pass positional argument 0 after keyword argument b=1, which is not allowed.

swatiexam

Why a is correct?

aldo63

becoz the given input of b already equals 0, we need input for a so it will yield: a*b