The quiz where the difficulty automagically adapts to the player's Python knowledge
This is a question page. You can use this page to bookmark a question. Start a new quiz!
Question #691
A closure, unlike a plain function, allows a function to access variables captured through the closure’s copies of their values or references, even when the function is invoked outside their scope. Looking at the code below:
def outerFunction(text):
text = text
def innerFunction():
print(text)
return innerFunction
myFunction = outerFunction('hello')
myFunction()
will return:
>>hello"
(geeksforgeeks.org/python-closures)
What is a closure?
— The Python Quiz (@thepythonquiz) January 8, 2021
A function that takes zero parameters
A function object that remembers values in enclosing scopes even if they are not present in memory
The last line of code of a program
Fragments of code that are never executed
👇 Comment the answer, like and retweet!
Question difficulty: 🔵🔵🔵🔵🔵