Exam PCAP All QuestionsBrowse all questions from this exam
Question 111

Which of the following lambda definitions are correct? (Choose two.)

    Correct Answer: A, C

    In Python, a lambda function is defined as an anonymous function expressed as 'lambda parameters: expression'. Option 'A' is correct because it properly creates a tuple from its parameters 'x' and 'y'. Option 'C' is also correct because the expression 'x//y - x%y' is valid and returns the result of integer division of 'x' and 'y' minus the remainder of 'x' divided by 'y'. Option 'B' is incorrect because 'return' cannot be used in a lambda function. Option 'D' is incorrect because the syntax is invalid for lambda functions.

Discussion
macxszOptions: AC

A. lambda x,y: (x,y) C. lambda x,y: x//y - x%y

seaverickOptions: AC

#question 111 #lambda x,y = x//y - x%y#SyntaxError: invalid syntax lambda x,y: (x,y) #lambda x,y: return x//y - x%y#SyntaxError: invalid syntax lambda x,y: x//y - x%y Tested: A,C

DezzoPalYeahOptions: AC

The answer is A,C