← 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])))
- A.[3, 1, 4]
- B.[3, 4, 8]
- C.[8]
- 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 →