Do you want BuboFlash to help you learning these things? Or do you want to add or correct something? Click here to log in or create user.



Question
a=10; b=20
def my_function():
    [...] a
    a=11; b=21
my_function()
print(a) #prints 11
print(b) #prints 20
Answer
global

Question
a=10; b=20
def my_function():
    [...] a
    a=11; b=21
my_function()
print(a) #prints 11
print(b) #prints 20
Answer
?

Question
a=10; b=20
def my_function():
    [...] a
    a=11; b=21
my_function()
print(a) #prints 11
print(b) #prints 20
Answer
global
If you want to change selection, open original toplevel document below and click on "Move attachment"

Parent (intermediate) annotation

Open it
ame is still not found, it searches the built-in namespace. Finally, if this fails then the interpreter raises a NameError exception. Consider the following code: a=10; b=20 def my_function(): <span>global a a=11; b=21 my_function() print(a) #prints 11 print(b) #prints 20 <span>

Original toplevel document (pdf)

owner: kkhosravi - (no access) - PYTHON_DATA_STRUCTURES_AND_ALGORITHMS.pdf, p27

Summary

statusnot learnedmeasured difficulty37% [default]last interval [days]               
repetition number in this series0memorised on               scheduled repetition               
scheduled repetition interval               last repetition or drill

Details

No repetitions


Discussion

Do you want to join discussion? Click here to log in or create user.