Python Quest

Track 10 · Lesson 5 of 12

itertools and functools

Combine, group, pair up and accumulate data with itertools, and build functions from functions with functools.reduce and partial.

About 45 minIntermediate4 exercises

You will be able to

  • Join iterables with chain and take a slice of any iterable with islice
  • Group consecutive records with groupby, sorting first so each key forms one group
  • Generate combinations and permutations, and running totals with accumulate
  • Fold a sequence into one value with functools.reduce and pre-fill arguments with functools.partial

Included with a Formula Quest membership

It has 4 graded exercises with feedback, hints and solutions. Python Quest is included in Formula Quest memberships that cover Python; membership and billing are managed on Formula Quest.

View Formula Quest memberships

Tracks 1 and 2, the first lesson of every track, the playground and the dataset library are free.