Quiz Yourself on Scope in Python

Test yourself on the scope with Python.

We'll cover the following...

Quiz

1.

What is the scope according to Python of the variable “x”?

x=5
def my_func(a, b):
   print(x)
   x = 5
   print(x)
A.

Local scope

B.

Global scope

C.

Nonlocal scope

D.

Error


1 / 3