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

What is the expected output of the following code?

    Correct Answer: D

    The code defines a function foo that takes three arguments: x, y, and z. The function returns the result of the lambda function x applied to y minus the lambda function x applied to z. In the print statement, the lambda function x is defined as lambda x: x % 2, which returns the remainder when x is divided by 2. When the lambda function is applied to 2, the result is 2 % 2, which is 0. When the lambda function is applied to 1, the result is 1 % 2, which is 1. Therefore, the result of foo(lambda x: x % 2, 2, 1) is 0 - 1, which equals -1.

Discussion
Dave304409Option: D

Correct

DKAT2023Option: D

D is correct

a4129fdOption: D

As tested in my IDE