ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(int(0.1 * 10), round(0.1 * 10, 10) == 1, 0.1 * 10 == 1)
  1. A. 1 False True
  2. B. 1 True True
  3. C. 0 True True
  4. D. 1 True False

Correct answer: B. 1 True True

0.1 * 10 is exactly 1.0 in binary, so int gives 1 and both comparisons are True. The rounding step is not needed here, so the answer is simply 1 True True.

More Python Programming questions

Exams that ask this topic