ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print(sum(map(int, '1234')), '1234'[::-1] == '4321')
  1. A. 1234 True
  2. B. 10 False
  3. C. 11 True
  4. D. 10 True

Correct answer: D. 10 True

The digits of 1234 add to 10, and reversing the string gives 4321, so the comparison is True.

More Python Programming questions

Exams that ask this topic