ProgrammingHardProduct-company MCQ pattern

What is printed?

What is printed?
def apply_twice(f):
    def wrapper(x):
        return f(f(x))
    return wrapper

@apply_twice
def inc(x):
    return x + 1

print(inc(5))
  1. A. 6
  2. B. 7
  3. C. 12
  4. D. 10

Correct answer: B. 7

apply_twice makes inc call the original increment function twice: f(f(5)) = f(6) = 7.

More Python Programming questions

Exams that ask this topic