Create your own Python code examples that demonstrate each of the following. Do not copy examples from the book or any other source. Try to be creative with your examples to demonstrate that you invented them yourself.
184 words
def test():
example_variable = "local value"
print(example_variable)
example_variable = "global value"
"""
result of the operation print(example_variable)
In this case, the variable has a global scope will be displayed:
global value
"""
print(example_variable)
"""
test() function call result
A local variable is defined in the body of the function :
example_variable
execution print(example_variable) inside a function
In this case, the variable has a local scope and the local value
of the function will be displayed:
local value
"""
test()
Comments
Leave a comment