Q. What is the output of the Python code: x = [1, 2, 3]; print(x * 2)?

A
[1, 2, 3, 1, 2, 3]
B
[2, 4, 6]
C
[1, 2, 3, 2]
D
Error
Solution:

The * operator with a list and an integer repeats the list, so [1, 2, 3] * 2 becomes [1, 2, 3, 1, 2, 3].

Entri PDF Icon

Get Question Bank

Strengthen Your Practice with our comprehensive question bank.

Entri Contact Image

Get Expert Advice for Free: Register for Your Free Consultation Now!