निम्नलिखित कोड का परिणाम क्या है ?
What is the output of the following code ?
n2=4
def s(n1):
print(n1)
n1 = n1 +2
n2=4
s(n2)
print(n2)
A)
B)
C)
D)
Explanation:
Here's how the code works:
n2
is4
globally.- Inside the function
s(n1)
,n1
is set to4
(fromn2
). - The function prints
4
(the value ofn1
). - Modifying
n1
inside the function doesn't affect the globaln2
. - After the function, the global
n2
remains4
.
Output: 4 4
Answer: (C) 4 4