🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← Quiz: itertools and functools: all 10 questions

Quiz: itertools and functools · Question 4 of 10

What does this print? (code)

What does this print?

from itertools import accumulate
print(list(accumulate([3, 1, 4])))
  1. A.[3, 1, 4]
  2. B.[3, 4, 8]
  3. C.[8]
  4. D.[3, 3, 4]
Answer & explanation

Correct answer: [3, 4, 8]

Running totals: 3, 3+1, 3+1+4.

Can you get the rest right without peeking?

Take the timed Quiz: itertools and functools quiz free. Pass it to earn XP and count towards your certificate.

Start the quiz →