What will the following Python code produce as a result? c(f) is a definition. inner(*args, **kargs): define inner(*args, **kargs): define inner(*args, **karg f(*args, **kargs) return inner.co += 1 return inner @c inner.co = 0 fnc() is a function that takes a parameter and returns a value. fnc() fnc() fnc() fnc() print if __name__ == '__main__' (fnc.co)
A. 4
B. 3
C. 0
D. 1
Answer:B
What will the following Python code produce as a result? c(f) is a definition. inner(*args, **kargs): define inner(*args, **kargs): define inner(*args, **karg f(*args, **kargs) return inner.co += 1 return inner @c inner.co = 0 fnc() is a function that takes a parameter and returns a value. fnc() fnc() fnc() fnc() print if __name__ == '__main__' (fnc.co)
A. 4 B. 3 C. 0 D. 1
Explanation: The above code calculates the number of times a function has been invoked. As a result, the code's output is 3