ProgrammingModerateTCS NQT · Accenture
What is printed?
What is printed?
import itertools print(list(itertools.accumulate([3, 1, 4], initial=10)))
- A. [10, 3, 4, 8]
- B. [13, 14, 18]
- C. [10, 13, 14, 18]
- D. [3, 4, 8]
Correct answer: C. [10, 13, 14, 18]
accumulate with initial=10 yields the starting value first, then each running sum: 10, 13, 14, 18.
More Python Programming questions
- What is printed? python from itertools import groupby s = 'aabbaa' print([(k, len(list(g))) for k, g in groupby(s)])
- What is printed? python print(sorted(['b', 'A', 'a', 'B'], key=str.lower))
- What is printed? python nums = map(int, '1 2 3'.split()) a = list(nums) b = list(nums) print(a, b)
- What is printed? python print(1020 + 1 - 1020, float(1020 + 1) - float(1020))
- What is printed? python data = [('b', 2), ('a', 2), ('c', 1), ('a', 1)] print(sorted(sorted(data, key=lambda t: t[0]), key=lambda t: t[1]…
- What is printed? python print(int('0x1F', 16), int('1F', 16), int('0b101', 0), int(' 42 '), int('42'))