ProgrammingVery hardJEE Advanced · CAT placement

What is printed?

What is printed?
x = 0.1
print((0.5).as_integer_ratio(), (0.1).as_integer_ratio()[1] == 2**55)
  1. A. (1, 2) False
  2. B. (1, 10) True
  3. C. (1, 2) True
  4. D. (1, 2) 2**55

Correct answer: C. (1, 2) True

0.5 is exactly one half, so its ratio is (1, 2). The float 0.1 is stored as a fraction with denominator 2**55, so the second check is True.

More Python Programming questions

Exams that ask this topic