ProgrammingModerateGATE CS · Product-company placement

What is printed?

What is printed?
x = [1, 2, 3]
print(x * 2, [x] * 2 == [[1, 2, 3], [1, 2, 3]], x + [4] is x, [] == False, not [])
  1. A. [2, 4, 6] True False False True
  2. B. [1, 2, 3, 1, 2, 3] True False True True
  3. C. [1, 2, 3, 1, 2, 3] False False False True
  4. D. [1, 2, 3, 1, 2, 3] True False False True

Correct answer: D. [1, 2, 3, 1, 2, 3] True False False True

* repeats a list rather than scaling it, and + builds a new list. An empty list is falsy but not EQUAL to False; == compares a list with a bool and returns False.

More Python Programming questions

Exams that ask this topic