Certified Associate in Python Programming (PCAP) — Question 106
Which of the following lambda definitions are correct? (Choose two.)
Answer options
- A. lambda x,y: (x,y)
- B. lambda x,y: return x//y - x%y
- C. lambda x,y: x//y - x%y
- D. lambda x,y = x//y - x%y
Correct answer: A, C
Explanation
The correct answers are A and C because option A defines a lambda that returns a tuple, which is valid syntax. Option C correctly defines a lambda function that performs arithmetic operations without using 'return', which is appropriate for lambda expressions. Options B and D are incorrect due to improper syntax; B incorrectly uses 'return' inside a lambda, and D has an incorrect assignment syntax.