ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(float('1e-3') * 1000 == 1, int(float('1e-3') * 1000), round(float('1e-3') * 1000))
  1. A. True 1 1
  2. B. False 0 1
  3. C. True 0 1
  4. D. True 1 0

Correct answer: A. True 1 1

1e-3 * 1000 happens to round to exactly 1.0 here, so the equality holds and int and round both give 1. Other numbers can land just under an integer, which is why int can differ from round.

More Python Programming questions

Exams that ask this topic