Skip to content
Related Articles

Related Articles

Python-Quizzes | Python List Quiz | Question 23
  • Last Updated : 17 Sep, 2020

Question 23: Find the output of the following program:




L1 = [1, 2, 3, 4
L2 = L1 
L3 = L1.copy() 
L4 = L1
L1[0] = [5
print(L1, L2, L3, L4) 

(A) [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4] [1, 2, 3, 4]
(B) [[5], 2, 3, 4] [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4]
(C) [5, 2, 3, 4] [5, 2, 3, 4] [5, 2, 3, 4] [1, 2, 3, 4]
(D) [[5], 2, 3, 4] [[5], 2, 3, 4] [1, 2, 3, 4] [[5], 2, 3, 4]


Answer: (D)

Explanation: List L2 is the Shallow copy of L1, while L3 and L4 are Deep Copy(True Copy) of List L1. L1[0] = [5], implies that at index 0, list [5] will be present and not integer value 5.

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :