ProgrammingModerateTCS NQT · Wipro pattern

What is printed?

What is printed?
print(10 // 3, 10 % 3, divmod(10, 3), (10 // 3) * 3 + 10 % 3)
  1. A. 3 1 (3, 1) 9
  2. B. 3 1 (3, 1) 10
  3. C. 3 2 (3, 2) 10
  4. D. 3 1 (3, 1) 11

Correct answer: B. 3 1 (3, 1) 10

10 // 3 is 3 and 10 % 3 is 1, and divmod returns both as a pair. Recombining them gives back 10.

More Python Programming questions

Exams that ask this topic