ProgrammingVery hardGATE CS & IT · Infosys
What is printed?
What is printed?
print(pow(2, 100, 97), 2 ** 100 % 97, (-2) ** 3 % 5, pow(-2, 3, 5))
- A. 16 16 2 2
- B. 16 16 -3 2
- C. 16 16 3 -3
- D. 15 16 2 2
Correct answer: A. 16 16 2 2
Fermat's little theorem gives 2^96 = 1 mod 97, so 2^100 = 2^4 = 16. Python's % and three-argument pow return values from 0 to m-1, so -8 % 5 is 2.
More Python Programming questions
- What is printed? python from itertools import permutations, combinations print(len(list(permutations('abcd', 2)))…
- What is printed? python def sqsorted(a): l, r = 0, len(a) - 1 out = [0] len(a) k = len(a) - 1 while l <= r: if abs(a[l]) > abs(a[r])…
- What is printed? python def minpath(g): dp = [0] len(g[0]) for i, row in enumerate(g): for j, v in enumerate(row): if i == 0 and j == 0…
- What is printed? python from functools import lrucache def wb(s, words): @lrucache(maxsize=None) def go(i): if i == len(s): return 1…
- What is printed? python from functools import cache @cache def ways(s, i=0): if i == len(s): return 1 if s[i] == '0': return 0 total =…
- What is printed? python import heapq words = ['bb', 'a', 'cc', 'dd', 'e'] print(heapq.nlargest(2, words, key=len), heapq.nsmallest(2…