ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
print(f'{2**70:,}'[:8], len(f'{2**70:,}'), str(2**70)[-3:], ('%d' % 2**70)[-3:])
  1. A. 1,180,59 29 423 424
  2. B. 1,180,591 30 424 424
  3. C. 1,180,59 28 424 424
  4. D. 1,180,59 29 424 424

Correct answer: D. 1,180,59 29 424 424

2**70 has 22 digits, so with 7 thousands separators the grouped form has 29 characters. The last three digits are 424, and %d gives the same digits as str.

More Python Programming questions

Exams that ask this topic