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

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

What is the output of the following program ?

def  myfunc(a):
    a=a+2
    a=a*2 
    return a 
print myfunc(2) 
A)
B)
C)
D)

Explanation:

Let's analyze the given Python code:

def myfunc(a):
    a = a + 2
    a = a * 2
    return a

print(myfunc(2))

Step-by-Step Explanation:

  1. Function Definition:

    • The function myfunc(a) takes one argument a.
    • Inside the function:
      • First, a = a + 2 increases a by 2.
      • Then, a = a * 2 doubles the new value of a.
    • Finally, the function returns the value of a.
  2. Function Call:

    • The function is called with a = 2, so:
      • a = 2 + 2a = 4
      • a = 4 * 2a = 8
    • The function then returns 8.
  3. Output:

    • The print(myfunc(2)) will print the returned value, which is 8.

Answer:

(A) 8

Latest Updates