Open In App

Python-Quizzes | Python List Quiz | Question 15

Like Article
Like
Save
Share
Report

Question 15: Find the output of the following program: 

Python3




list = ['a', 'b', 'c'] * -3
print(list)


(A)

[\’a\’, \’b\’, \’c\’, \’a\’, \’b\’, \’c\’, \’a\’, \’b\’, \’c\’]

(B)

[\’c\’, \’b\’, \’a\’, \’c\’, \’b\’, \’a\’, \’c\’, \’b\’, \’a\’]

(C)

[ ]

(D)

[\’a\’, \’b\’, \’c\’]


Answer: (C)

Explanation:

An expression list[listelements]*N where N is an integer appends N copies of list elements in the original list. If N is a negative integer or 0 output will be an empty list else if N is positive list elements will be added N times to the original list.


Quiz of this Question
Please comment below if you find anything wrong in the above post


Last Updated : 17 Sep, 2020
Like Article
Save Article
Previous
Next
Share your thoughts in the comments
Similar Reads