Exam PCAP All QuestionsBrowse all questions from this exam
Question 60

A two-parameter lambda function raising its first parameter to the power of the second parameter should be declared as:

    Correct Answer: D

    A lambda function in Python is declared using the syntax `lambda parameters: expression`. In this case, to raise the first parameter to the power of the second parameter, the correct declaration is `lambda x, y: x ** y`.

Discussion
macxszOption: D

D. lambda x, y: x ** y

NiteshSinghOption: D

D is the correct answer. d = lambda x,y:x**y print (d(2,3)) ====================== RESTART: C:\xxxxxxn.py ===================== 8 >>>

EfrenOption: D

Correct: >>> lambda x,y:x**y <function <lambda> at 0x0000027F6788C268> >>> lambda(x,y)=x**y File "<stdin>", line 1 lambda(x,y)=x**y ^ SyntaxError: invalid syntax >>> def lambda(x,y): return x**y File "<stdin>", line 1 def lambda(x,y): return x**y ^ SyntaxError: invalid syntax

NiteshSingh

You have to use it like below - d = lambda x,y:x**y print (d(2,3))