⊗pyPmFnGVS 2 of 128 menu

Global scope of variables in Python

If we move the variable num from the function to the outer code block, it will acquire global visibility and will become accessible not only inside the function, but also outside:

num = 1 def func(): print(num) func() # 1

What will be the result of running the following code:

num = 2 def func(): return num func() print(num)

What will be the result of running the following code:

num = 2 def func(): return num1 print(func())
enru