ProgrammingVery hardCAT · MBA placement
What is printed?
What is printed?
print(sum(range(10**6)) % 7)
- A. 1
- B. 3
- C. 6
- D. 0
Correct answer: D. 0
The sum equals 10^6 times (10^6 - 1) divided by 2. Because 10^6 is 1 modulo 7, the factor 10^6 - 1 is divisible by 7, so the sum is a multiple of 7.
More Python Programming questions
- What is printed? python print(12 & -12, 12 ^ 12 >> 1)
- What is printed? python print(list(map(lambda a, b: a b, [1, 2, 3], [4, 5])))
- What is printed? python print(max([], default=-1), min(range(0), default='e'))
- What is printed? python from itertools import takewhile, dropwhile a = [1, 3, 5, 2, 7, 1] print(list(takewhile(lambda x: x % 2, a))…
- What is printed? python print(next(iter([]), 'none'), next(iter([7])))
- What is printed? python x = 3.14159 print(f'{x:.2f}|{42:>5}|{0.5:%}')