PCAP Exam QuestionsBrowse all questions from this exam

PCAP Exam - Question 60


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

Show Answer
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

3 comments
Sign in to comment
EfrenOption: D
Apr 17, 2021

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
Oct 10, 2021

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

NiteshSinghOption: D
Oct 10, 2021

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

macxszOption: D
May 3, 2022

D. lambda x, y: x ** y