ProgrammingHardTCS NQT · Infosys HackWithInfy · Product Company SDE

What does the following Python 3 code print? x = [1, 2, 3] y = [1, 2, 3] print(x == y, x is y)

  1. A. False False
  2. B. True False
  3. C. False True
  4. D. True True

Correct answer: B. True False

== compares values (equal contents), while is compares identity; x and y are two distinct list objects with the same contents.

More Python Programming questions

Exams that ask this topic