Quiz Yourself on Scope in Python

Test yourself on the scope with Python.

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

Question 1 of 30 attempted

Get hands-on with 1200+ tech skills courses.