Python Programming - Tricky Questions - Discussion
Discussion Forum : Tricky Questions - General Questions (Q.No. 40)
40.
Consider the following Python code:
def my_decorator(func):
def wrapper(*args, **kwargs):
result = func(*args, **kwargs)
return result * 2
return wrapper
@my_decorator
def my_function(x):
return x + 1
result = my_function(5)
print(result)
What will be the value of result
?
Answer: Option
Explanation:
The decorator multiplies the result of the function by 2.
Discussion:
Be the first person to comment on this question !
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers