🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित पायथन प्रोग्राम का आउटपुट ____ है

The output of following Python program is _____.

r = lambda q: q*2
s = lambda q: q * 3
x = 2
x = r(x)
x = s(x) 
x = r(x)
print x
A)
B)
C)
D)

Explanation:

Let's break down the given Python code step by step:

r = lambda q: q * 2
s = lambda q: q * 3
x = 2
x = r(x)
x = s(x)
x = r(x)
print(x)

Step-by-Step Explanation:

  1. Define the lambdas:

    • r = lambda q: q * 2: This lambda function doubles the input.
    • s = lambda q: q * 3: This lambda function triples the input.
  2. Initial value of x:

    • x = 2
  3. Apply r(x):

    • x = r(x) means x = 2 * 2 = 4. Now, x is 4.
  4. Apply s(x):

    • x = s(x) means x = 4 * 3 = 12. Now, x is 12.
  5. Apply r(x) again:

    • x = r(x) means x = 12 * 2 = 24. Now, x is 24.
  6. Final output:

    • print(x) prints the final value of x, which is 24.

Answer:

(B) 24

Latest Updates