PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 22


Select the valid fun () invocations:

(Choose two.)

Show Answer
Correct Answer: BD

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

8 comments
Sign in to comment
diazed
Jan 17, 2022

Those are the correct answers

macxszOptions: BD
May 3, 2022

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

N9Options: BD
Sep 3, 2022

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

Monika23Options: BD
Apr 5, 2023

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

swatiexam
Apr 5, 2022

Why a is correct?

aldo63
Feb 15, 2023

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

TheFivePipsOptions: BD
Dec 8, 2023

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.

4a348e6Options: BD
May 7, 2024

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.

4a348e6
May 7, 2024

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