Skip to content
KALANBLON
Show contents

Chapter 3 of 7 · 10 min

Quiz: iterating with style

Iterators, generators, comprehensions and functional tools: let's check you iterate like a pro. You need 70 % correct answers, and every answer is explained.

Quiz

5 questions · pass mark: 70%

  1. 1.What happens when you call a function that contains yield?

    One answer

  2. 2.What does this code display?

    One answer

    g = (x * 2 for x in [1, 2, 3])
    print(sum(g), sum(g))
  3. 3.Which statements about itertools.groupby are true? (several answers)

    Several answers possible

  4. 4.Complete the decorator that memorises a pure function's results.

    Complete the code

    from functools import _________
    
    @_________(maxsize=None)
    def fib(n): ...
  5. 5.What does {w.lower(): len(w) for w in ["Hola", "hola"]} contain?

    One answer

Your progress is saved on this device. Create a free account to keep your progress on all your devices.