MCQ Answer

<p>What will be the output of the following Python code?</p><pre><span style="font-size: 14px;">def f1(a,b=[]):<br></span><span style="font-size: 14px;">&nbsp; &nbsp; b.append(a)<br></span><span style="font-size: 14px;">&nbsp; &nbsp; return b<br></span><span style="font-size: 14px;">print(f1(2,[3,4]))</span></pre><div><br></div>

What will be the output of the following Python code?

def f1(a,b=[]):
    b.append(a)
    return b
print(f1(2,[3,4]))



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

def f1(a,b=[]):
    b.append(a)
    return b
print(f1(2,[3,4]))
Topic : Functions in Python

A. [3,2,4]

B. [2,3,4]

C. Error एरर

D. [3,4,2]




Correct Answer is :

D. [3,4,2]



Explanation
In the code shown above, the integer 2 is appended to the list [3,4]. Hence the output of the code is [3,4,2]. Both the variables a and b are local variables.
Latest Current Affairs 2024 Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2024 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