ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(10 ** -3 * 1000 == 1, 10 ** -3 * 1000)
  1. A. False 1.0
  2. B. True 1.0
  3. C. True 1
  4. D. True 0.9999999999999999

Correct answer: B. True 1.0

10 ** -3 is the float 0.001, and multiplying it by 1000 rounds to exactly 1.0. The result is a float, so it prints as 1.0 rather than 1.

More Python Programming questions

Exams that ask this topic