ProgrammingVery hardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(10 ** 18 % 7, (10 ** 18 + 2) // 4, -(2 ** 63) // (2 ** 62))
- A. 1 250000000000000000 -2
- B. 1 250000000000000001 -2
- C. 2 250000000000000000 -2
- D. 1 250000000000000000 -1
Correct answer: A. 1 250000000000000000 -2
10**18 mod 7 is 1 because 10 mod 7 is 3, and 3**18 mod 7 equals 1 by Fermat's little theorem. (10**18 + 2) // 4 is 250000000000000000 exactly, and -(2**63) // 2**62 is -2.
More Python Programming questions
- What is printed? python lst = list(range(5)) lst[1:4] = [] try: lst[::2] = [9, 9] except ValueError: print('ValueError', lst)
- What is printed? python def dedupe(a): if not a: return 0 k = 1 for i in range(1, len(a)): if a[i] != a[k - 1]: a[k] = a[i] k += 1 return…
- What is printed? python def firsttrue(lo, hi, ok): while lo < hi: mid = (lo + hi) // 2 if ok(mid): hi = mid else: lo = mid + 1 return lo…
- What is printed? python def search(a, t): lo, hi = 0, len(a) - 1 while lo <= hi: mid = (lo + hi) // 2 if a[mid] == t: return mid if a[lo]…
- What is printed? python import bisect a = sorted(['10', '9', '100', '20']) print(a, bisect.bisectleft(a, '9'), [int(x) for x in a])
- What is printed? python def arrows(p): p = sorted(p, key=lambda x: x[1]) cnt = 0 end = None for s, e in p: if end is None or s > end: cnt…