MCQ Answer

<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))
Topic : Functions in Python

A. True सही

B. False गलत

C. None कोई नहीं

D. Error एरर




Correct Answer is :

A. True



Explanation
The same object is modified in the function.
CCC Online Test 2021 CCC Practice Test Hindi Python Programming Tutorials Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Bank SSC Railway TET UPTET Question Bank career counselling in allahabad Sarkari Naukari Notification Best Website and Software Company in Allahabad Sarkari Exam Quiz