निम्नलिखित कोड का परिणाम क्या है ?
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
6 4
B
4 6
C
4 4
D
6 6
Explanation
Here's how the code works:
n2is4globally.- Inside the function
s(n1),n1is set to4(fromn2). - The function prints
4(the value ofn1). - Modifying
n1inside the function doesn't affect the globaln2. - After the function, the global
n2remains4.
Output: 4 4
Answer: (C) 4 4
Correct Answer: C) 4 4