Report Bug

Qus

What will be the output of the following Python code?

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

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

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


A. [3,2,4]
B. [2,3,4]
C. Error
D. [3,4,2]


Solution
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.
Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 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 Best Website and Software Company in Allahabad