ProgrammingHardTCS NQT · Infosys

What is printed?

What is printed?
x = 5
x += 2 * x
print(x, x - 2 * 3 ** 2 // 9 ** 1, x // 4 * 4 + x % 4)
  1. A. 15 13 15
  2. B. 15 11 15
  3. C. 15 13 16
  4. D. 16 13 15

Correct answer: A. 15 13 15

x becomes 5 + 10 = 15. 2 * 3 ** 2 // 9 ** 1 is 18 // 9 = 2, so the second value is 13. x // 4 * 4 + x % 4 rebuilds 15.

More Python Programming questions

Exams that ask this topic