ProgrammingHardTCS NQT · Wipro pattern
What is printed?
What is printed?
print(sum(range(10 ** 6)) % 1000, sum(range(1, 11)) // 5)
- A. 0 10
- B. 500 11
- C. 0 11
- D. 5 11
Correct answer: C. 0 11
The sum of 0 to 999999 is 499999500000, which ends in 000 and so is 0 mod 1000. The sum of 1 to 10 is 55, and 55 // 5 is 11.
More Python Programming questions
- What is printed? python print(('a' 'b' 'c').upper(), 'x' 'y' 2, ('%d' % 3) 2)
- What is printed? python print(1e16 == 1016, 1e16 + 1 == 1016 + 1, 1e16 + 2 == 1016 + 2, int(1e16) + 1)
- What is printed? python print('%.2e' % 0, '%.1f' % 2.25, '%.1f' % 2.35, '%5.1f|' % -0.04)
- What is printed? python x = 0.1 print((0.5).asintegerratio(), (0.1).asintegerratio()[1] == 255)
- What is printed? python import operator print(operator.index(5), operator.mod(-7, 3), operator.floordiv(-7, 3))
- What is printed? python print(sorted(['b', 'B', 'a', 'A'], key=lambda s: s.swapcase()))