qobjects = [
{
question: "What is the main purpose of a decorator in Python?",
options: [
"To permanently modify a function's source code",
"To automatically convert all return values to uppercase",
"To wrap a function and extend/modify its behavior without changing its source",
"To compile Python code to C for performance"
],
correct: 2
},
{
question: "What does functools.wraps do when used inside a decorator?",
options: [
"It preserves the original function's metadata (name, docstring, signature)",
"It speeds up the wrapped function",
"It prevents the decorator from running more than once",
"It logs each call to the function automatically"
],
correct: 0
},
{
question: "What is the output of the following code?def upper(f):",
options: [
"hi!",
"HI!",
"HI",
"Hi!"
],
correct: 1
}
]
def w():
return f().upper()
return w
def exclaim(f):
def w():
return f() + \"!\"
return w
@upper
@exclaim
def say():
return \"hi\"
print(say())