ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(10 ** 17 in range(0, 10 ** 18, 2), 10 ** 17 + 1 in range(0, 10 ** 18, 2))
- A. False False
- B. False True
- C. True False
- D. True True
Correct answer: C. True False
A range containment test for ints is a constant-time arithmetic check: it verifies the bounds and that (x - start) is a multiple of the step. 10**17 is even, while 10**17 + 1 is not.
More Python Programming questions
- What is printed? python def add(x, memo={}): memo[x] = len(memo) return memo print(add(5), add(7))
- What is printed? python print(min('10', '9'), min(10, 9), max('10', '9', key=int))
- What is printed? python i = 'x' = [i for i in range(3)] print(i)
- What is printed? python print([y for x in range(5) if (y := x x) > 5])
- What is printed? python print(bin(10).count('1'), (10).bitcount(), (-10).bitcount())
- What is printed? python from collections import Counter print(Counter('abracadabra').mostcommon(3))