ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
print(3 ** 3 ** 0, (3 ** 3) ** 0, 0 ** 3 ** 0, (0 ** 3) ** 0)
  1. A. 1 1 0 1
  2. B. 3 1 1 1
  3. C. 3 0 0 1
  4. D. 3 1 0 1

Correct answer: D. 3 1 0 1

** is right-associative, so 3 ** 3 ** 0 is 3 ** 1 = 3. 0 ** 1 is 0, while (0 ** 3) ** 0 is 0 ** 0 = 1.

More Python Programming questions

Exams that ask this topic