Python-Quizzes | Python List Quiz | Question 9

Question 9: Find the output of the following program:

filter_none

edit
close

play_arrow

link
brightness_4
code

list1 = [1998, 2002
list2 = [2014, 2016
  
print ((list1 + list2)*2)

chevron_right


(A) [1998, 2002, 2014, 2016, 1998, 2002, 2014, 2016]
(B) [1998, 2002, 2014, 2016]
(C) [1998, 2002, 1998, 2002]
(D) [2014, 2016, 2014, 2016]


Answer: (A)

Explanation: When the addition(+) operator uses a list as its operands then the two lists will get concatenated. And when a list id multiplied with a constant k>=0 then the same list is appended k times in the original list.

Quiz of this Question

My Personal Notes arrow_drop_up
Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.