ProgrammingHardTCS CodeVita · Infosys HackWithInfy

What is printed?

What is printed?
import math
print(math.floor(7 / 2) * 2 + 7 % 2, 7 // 2 * 2 + 7 % 2)
  1. A. 7 7
  2. B. 6 7
  3. C. 7 6
  4. D. 8 6

Correct answer: A. 7 7

math.floor(3.5) and 7 // 2 are both 3, and 7 % 2 is 1, so each expression is 3 * 2 + 1 = 7.

More Python Programming questions

Exams that ask this topic