Python closures allow inner functions to capture and remember variables from their enclosing scopes, even after the outer function has finished executing. This quiz helps you understand closures with practical examples and core concepts.
Time limit: 0
Quiz Summary
0 of 15 Questions completed
Questions:
Information
You have already completed the quiz before. Hence you can not start it again.
What happens to the variable x after the outer function exits in a closure?
Correct
Incorrect
Question 5 of 15
5. Question
How do you check if a function is a closure?
Correct
Incorrect
Question 6 of 15
6. Question
Which of the following is a real-world use case of closures?
Correct
Incorrect
Question 7 of 15
7. Question
What will this print?
def multiplier(factor): def multiply(n): return n * factor return multiply
double = multiplier(2) print(double(5))
Correct
Incorrect
Question 8 of 15
8. Question
Which statement is true about closures?
Correct
Incorrect
Question 9 of 15
9. Question
What does f.__closure__ contain in a closure?
Correct
Incorrect
Question 10 of 15
10. Question
What is the output?
def outer(): x = 100 def inner(): print(x) return inner
f = outer() del outer f()
Correct
Incorrect
Question 11 of 15
11. Question
Closures are a feature of which programming concept?
Correct
Incorrect
Question 12 of 15
12. Question
Which is NOT a benefit of closures?
Correct
Incorrect
Question 13 of 15
13. Question
In what scenario is a closure created automatically?
Correct
Incorrect
Question 14 of 15
14. Question
Can a closure reference multiple variables from the enclosing function?
Correct
Incorrect
Question 15 of 15
15. Question
Why are closures preferred over global variables?
Correct
Incorrect
Summary
Python closures help preserve state and maintain clean encapsulation in functional code using the yield and enclosing scope. They are widely used in decorators, callback functions, and stateful logic without using classes or globals.
At QuizOrbit, our team specializes in fun, informative quizzes across topics like general knowledge, technology, and entertainment. Boost your knowledge with our expert-designed quizzes.