Skip to content
KALANBLON
Show contents

Chapter 7 of 7 · 10 min

Quiz: functions and resources

Closures, decorators, context managers and log analysis: last quiz of this course. You need 70 % correct answers to pass it.

Quiz

5 questions · pass mark: 70%

  1. 1.What is @log placed above def compute(…) equivalent to?

    One answer

  2. 2.Why use functools.wraps in a decorator?

    One answer

  3. 3.Complete the keyword that lets an inner function change a variable of the enclosing function.

    Complete the code

    def counter():
        total = 0
        def add(n):
            ________ total
            total += n
  4. 4.The body of a with block raises an exception. What does Python do?

    One answer

  5. 5.In a manager written with @contextmanager, which statements are true? (several answers)

    Several answers possible

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