ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(int(2.9999999999999996), float('1e400'), -float('1e400'), 1e308 * 10 == float('inf'))
  1. A. 2 inf -inf False
  2. B. 3 inf -inf True
  3. C. 2 inf -inf True
  4. D. 2 1e400 -1e400 True

Correct answer: C. 2 inf -inf True

2.9999999999999996 is the largest double below 3, so int truncates it to 2. Literals that overflow a double become infinity, and multiplying a huge finite float by 10 also overflows to inf.

More Python Programming questions

Exams that ask this topic