NIELIT O Level Exam

<p>What will be the output of the following Python code?</p><pre><span style="font-size: 14px;">def foo(x):<br></span><span style="font-size: 14px;">&nbsp; &nbsp; x[0] = ['def']<br></span><span style="font-size: 14px;">&nbsp; &nbsp; x[1] = ['abc']<br></span><span style="font-size: 14px;">&nbsp; &nbsp; return id(x)<br></span><span style="font-size: 14px;">q = ['abc', 'def']<br></span><span style="font-size: 14px;">print(id(q) == foo(q))</span></pre>

What will be the output of the following Python code?

def foo(x):
    x[0] = ['def']
    x[1] = ['abc']
    return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))


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

def foo(x):
    x[0] = ['def']
    x[1] = ['abc']
    return id(x)
q = ['abc', 'def']
print(id(q) == foo(q))

A. True सही

B. False गलत

C. None कोई नहीं

D. Error एरर




Correct Answer is :

A. True



Explanation
The same object is modified in the function.
Latest Current Affairs 2025 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Online MBA 2 years Online MCA Online BCA Best Website and Software Company in Allahabad