PCAP-31-03 Exam QuestionsBrowse all questions from this exam

PCAP-31-03 Exam - Question 38


Assuming that the following code has been executed successfully, select the expressions which evaluate to True (Choose two.)

Show Answer
Correct Answer: AC

The function `f(x, y)` returns a function `g()` that calculates the quotient of `nom` and `denom`. Since the parameters `x` and `y` are set when calling `f`, `a` and `b` are indeed functions and not `None`. Moreover, `a` is a closure capturing `1` and `2` while `b` is a closure capturing `3` and `4`, meaning `a` and `b` are two different function instances, thus `a != b` is true. However, the statements `a() == 4` and `b() == 4` are incorrect because `a()` would return `0.5` (i.e., `1 / 2`) and `b()` would return `0.75` (i.e., `3 / 4`). Therefore, the correct answers are A and C.

Discussion

3 comments
Sign in to comment
DKAT2023Options: AC
Jul 1, 2024

A and C are correct

a4129fdOptions: AC
May 30, 2024

As tested

Dave304409Option: C
Jul 3, 2024

C is correct

Dave304409
Jul 3, 2024

A, C us correct