ProgrammingHardGATE CS · Product-company placement
What is printed?
What is printed?
print(2**100 % 7, pow(2, 100, 7), pow(2, 100, 1))
- A. 2 2 1
- B. 4 2 0
- C. 2 2 0
- 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
- What is printed? python x = 1020 print(x // 3, x / 3 == x // 3, x % 3)
- What is printed? python n = int('9' 30) print(len(str(n + 1)), (n + 1) - 1030)
- What is printed? python print(5 & 3, 5 | 3, 5 ^ 3, ~5, 5 << 2, -5 >> 1)
- What is printed? python print(-1 & 0xFF, -8 >> 1, -1 >> 100, -9 & 7)
- What is printed? python print(1 << 64 == 264, (1 << 64) - 1 & 0xFFFF)
- What is printed? python print(0.1 + 0.2 == 0.3, round(0.1 + 0.2, 10) == 0.3, 0.1 + 0.2)