ProgrammingModerateTCS NQT · Infosys

What is printed?

What is printed?
print(float(3) / 2 == 1.5, 3 // 2.0, 3 / 2.0 // 1)
  1. A. True 1 1.0
  2. B. True 1.0 1
  3. C. False 1.0 1.0
  4. D. True 1.0 1.0

Correct answer: D. True 1.0 1.0

Division with / always gives a float, and // with a float operand gives a float too. The results are 1.5 == 1.5, then floor(1.5) = 1.0 in both cases.

More Python Programming questions

Exams that ask this topic