Tuesday, September 15, 2026

Python Lambda Quiz

 Python Lambda Quiz


1. What will be the output? x = 4 f = lambda x: x + 2 print(f(3) + x)

   A. 9

   B. 7

   C. 12

   D. 10


2. What will be the output? square = lambda x: x * x print(square(5))

   A. 25

   B. 20

   C. 10

   D. 15


3. What will be the output? add = lambda a, b: a + b print(add(4, 6))

   A. 24

   B. 10

   C. 2

   D. 46


4. What will be the output? f = lambda x: x * 2 print(f(3) + f(4))

   A. 11

   B. 14

   C. 24

   D. 12


5. What will be the output? f = lambda x: x - 1 print(f(10))

   A. 10

   B. 9

   C. 1

   D. 11

1 comment:

perlknowledge said...

What will be the output?

x = 4 f = lambda x: x + 2 print(f(3) + x)

The function call gives 3 + 2 = 5, and the outer x remains 4, so 5 + 4 = 9.

What will be the output?

square = lambda x: x \* x print(square(5))

Substituting 5 gives 5 × 5 = 25.

What will be the output?

add = lambda a, b: a + b print(add(4, 6))

The lambda adds 4 and 6, producing 10.

What will be the output?

f = lambda x: x \* 2 print(f(3) + f(4))

f(3) is 6 and f(4) is 8, so 6 + 8 = 14.

What will be the output?

f = lambda x: x - 1 print(f(10))

Substituting 10 into x − 1 gives 9.