ProgrammingHardTCS CodeVita · Infosys HackWithInfy
What is printed?
What is printed?
print(sum(range(0, 101, 5)), len(range(0, 101, 5)))
- A. 1050 21
- B. 1050 20
- C. 1000 21
- D. 1055 21
Correct answer: A. 1050 21
The values are 0, 5, ..., 100, which is 21 numbers. Their sum is 5 times 0 + 1 + ... + 20, which is 5 * 210 = 1050.
More Python Programming questions
- What is printed? python print(bin(37)[2:].zfill(8), int('100101', 2) == 37)
- What is printed? python import heapq h = [] for x in [5, 2, 8]: heapq.heappush(h, x) print(heapq.heappop(h), heapq.heappop(h), h)
- What is printed? python print(sorted([3, 1, 2], key=lambda x: -x)[0], max([3, 1, 2], key=lambda x: -x))
- What is printed? python print([x for x in range(20) if x % 3 == 0 and x % 4 == 0])
- What is printed? python print(len({(i, j) for i in range(3) for j in range(3) if i <= j}))
- What is printed? python print(sum(1 for c in 'Hello World' if c.isupper()), 'Hello World'.count('o'))