ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(int('12') + int('3'), '12' + '3', 12 + 3 == int('15'), 'x')
  1. A. 15 123 False x
  2. B. 15 15 True x
  3. C. 123 15 True x
  4. D. 15 123 True x

Correct answer: D. 15 123 True x

int('12') + int('3') is 15, while '12' + '3' concatenates the strings to 123. 12 + 3 equals int('15'), so the comparison is True.

More Python Programming questions

Exams that ask this topic