ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(7.0 == 7, (7.0).is_integer(), (7.5).is_integer(), 1e3 == 1000)
  1. A. True False False True
  2. B. True True True True
  3. C. True True False True
  4. D. True True False False

Correct answer: C. True True False True

Float and int compare by value, so 7.0 == 7 and 1e3 == 1000 are True. is_integer() is True only when the float has no fractional part, which is true for 7.0 but not 7.5.

More Python Programming questions

Exams that ask this topic