ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(len(str(float(10**16))), str(10**16 * 1.0), len(str(10**16)))
  1. A. 5 1e+16 17
  2. B. 17 1e+16 17
  3. C. 5 10000000000000000.0 17
  4. D. 5 1e+16 16

Correct answer: A. 5 1e+16 17

str of a float at 1e16 switches to exponent form, so the text is 1e+16 with five characters. The int 10**16 has 17 digits, which is why the two lengths differ.

More Python Programming questions

Exams that ask this topic