Report Bug

Qus

What is the output of following?

a = [1, 2, 3]
b = a
b.append(4)
print(a)
Qus

निम्न code का output क्या होगा?

a = [1, 2, 3]
b = a
b.append(4)
print(a)


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


Solution
B. [1, 2, 3, 4]



Explanation
a and b refer to the same list object, so modifying b also changes the list seen through a. <br><br> a और b एक ही list object को refer करते हैं, इसलिए b में change करने पर a में भी वही change दिखाई देता है।
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