ProgrammingVery hardProduct-company MCQ pattern
Which line is printed?
Which line is printed?
print(divmod(2**70, 10**6)[1] == 2**70 % 10**6, divmod(-2**70, 10**6)[1] == (-2**70) % 10**6, (-2**70) // 10**6 == -(2**70 // 10**6) - 1)
- A. True True False
- B. True True True
- C. False True True
- D. True False True
Correct answer: B. True True True
divmod and the % operator agree on the remainder, and floor division of a negative value is one less than the negated quotient unless the division is exact. 2**70 is not divisible by 10**6, so the last test holds.
More Python Programming questions
- What is printed? python from collections import Counter print(Counter('mississippi').mostcommon(3))
- What is printed? python from functools import lrucache @lrucache(None) def total(xs): return sum(xs) try: print(total([1, 2, 3])) except…
- What is printed? python import bisect print(bisect.bisectleft(range(100), True, key=lambda x: x x >= 50))
- What is printed? python n = 30 s = [True] (n + 1) s[0] = s[1] = False for i in range(2, int(n 0.5) + 1): if s[i]: s[i i::i] = [False]…
- What is printed? python print(-0.0 == 0.0, str(-0.0), repr(0.0 -1))
- What is printed? python print(float('1000.5'), end=' ') try: int('10') except ValueError: print('VE')