🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← All topics

Quiz: Scope and Closures: questions with answers

10 questions, each with the answer and a short explanation.

Take the timed quiz + get a certificate →
  1. Q1. In which order does Python search for a name?
  2. Q2. What does this print? (code)
  3. Q3. What does this print? (code)
  4. Q4. What error do you get if an inner function does count += 1 on an enclosing variable without nonlocal?
  5. Q5. What is a closure?
  6. Q6. What does this print? (code)
  7. Q7. Given def f(a, , b):, which call is valid?
  8. Q8. What does / mean in def area(r, /, unit="cm"):?
  9. Q9. What does this print? (code)
  10. Q10. What is the value of middle after a, middle, z = "python"?