Skills101
← All practice quizzes

Quiz: itertools and functools

5 questions · new set on every retakeNo time limitPass: 60%+10 XP on first pass

Two standard modules that replace many hand-written loops. Generate permutations, combinations and products, run totals with accumulate, group with groupby, and use reduce, partial, cache and cmp_to_key.

Log in to take the quiz

Free account · see your score, answers and explanations, earn XP

  1. Question 1

    How many items does combinations("ABCD", 2) produce?

  2. Question 2

    What does this print?

    from itertools import permutations
    print(len(list(permutations("ABC"))))
    
  3. Question 3

    Choosing a class monitor and a deputy from 10 students is which kind of count?

  4. Question 4

    What does this print?

    from itertools import accumulate
    print(list(accumulate([3, 1, 4])))
    
  5. Question 5

    Why should you usually sort before using groupby?

🎯 Today’s placement challenge — 10 questions, no login. Can you score 10/10?Take today’s challenge →