ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(str(12345)[::-1], int(str(12345)[::-1]) + 1, sum(int(d) for d in str(12345)), len(str(0)))
  1. A. 54321 54322 15 1
  2. B. 12345 54322 15 1
  3. C. 54321 54321 15 1
  4. D. 54321 54322 16 1

Correct answer: A. 54321 54322 15 1

Reversing the digit string gives 54321, and adding 1 to its integer value gives 54322. The digit sum of 12345 is 15, and str(0) has one character.

More Python Programming questions

Exams that ask this topic