Exam PCAP-31-03 All QuestionsBrowse all questions from this exam
Question 38

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

    Correct Answer: A, C

    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
DKAT2023Options: AC

A and C are correct

a4129fdOptions: AC

As tested

Dave304409Option: C

C is correct

Dave304409

A, C us correct