ProgrammingHardTCS NQT · Wipro pattern

What is printed?

What is printed?
print(int(str(10**20 + 1)[-1]) + len(str(10**20)), 10**20 + 1 == int(str(10**20 + 1)))
  1. A. 22 True
  2. B. 21 True
  3. C. 22 False
  4. D. 21 False

Correct answer: A. 22 True

The last digit of 10**20 + 1 is 1, and str(10**20) has 21 characters, so the sum is 22. Converting the string back gives the same integer, so the comparison is True.

More Python Programming questions

Exams that ask this topic