ProgrammingHardGATE CS · Product-company placement

What is printed?

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

Correct answer: C. 2 2 0

2 cubed is 8, which is 1 mod 7, and 100 = 3 * 33 + 1, so 2 to the power 100 is congruent to 2. Any value modulo 1 is 0.

More Python Programming questions

Exams that ask this topic