Enclosingscope
Mon 10 August 2026
def outer():
x = 5
def inner():
print(x)
Score: 10
Category: chapter1
def outer():
x = 5
def inner():
print(x)
Score: 10
Category: chapter1
x = 100
def show():
print(x)
Score: 10
Category: chapter1
Read Moredef func():
x = 10 # Local scope
Score: 10
Category: chapter1
Read Moreprint(a is b)
Score: 5
Category: chapter1
Read Morea = [1, 2, 3]
b = a
Score: 10
Category: chapter1
Read Morecount = 0
def increment():
global count
count += 1
Score: 10
Category: chapter1
Read Moredef outer():
total = 0
def inner():
nonlocal total
total += 1
Score: 10
Category: chapter1
Read More
Score: 5
Category: chapter1
Read More