Quiz: Advanced Functions and Decorators
Test your understanding of higher-order functions, decorators, factories, and context managers through difficult, scenario-based multiple-choice questions.
We'll cover the following...
We'll cover the following...
Technical Quiz
1.
Consider the following code regarding function references. What is the output?
def speak(text):
return f"Speaking: {text}"
def shout(text):
return f"SHOUTING: {text.upper()}"
def process(func, message):
# Notice we are assigning the function to a new variable name
action = func
return action(message)
print(process(speak, "hello"))
print(process(shout, "hello"))
A.
Speaking: hello followed by SHOUTING: HELLO
B.
Speaking: hello followed by Speaking: hello
C.
SHOUTING: HELLO followed by SHOUTING: HELLO
D.
TypeError: 'action' object is not callable
1 / 10
...