ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(1 == 1.0 and '1' != 1, [1, 2] == [1.0, 2.0], (1, 'a') == (1.0, 'a'))
  1. A. True True True
  2. B. True False True
  3. C. False True True
  4. D. True True False

Correct answer: A. True True True

Numbers of different types compare by value, so 1 == 1.0 holds, and lists and tuples compare element by element. A string is never equal to a number.

More Python Programming questions

Exams that ask this topic