Complete the code to print the value of the variable inside the function.
def greet(): message = 'Hello!' print([1]) greet()
The variable message is defined inside the function, so we use its name to print its value.
Complete the code to access the global variable inside the function.
count = 5 def show_count(): print([1]) show_count()
The variable count is defined outside the function, but it can be accessed inside because it is global.
Fix the error by completing the code to modify the global variable inside the function.
counter = 10 def increase(): global [1] counter += 1 increase() print(counter)
To change a global variable inside a function, you must declare it with global and use the exact variable name.
Fill both blanks to create a local variable and print it inside the function.
def show(): [1] = 'Local' print([2]) show()
print as a variable.The variable text is created locally and printed inside the function.
Fill all three blanks to create a global variable, modify it inside a function, and print the updated value.
value = 3 def update(): global [1] [2] += 7 update() print([3])
We declare value as global, modify it inside the function, and print it outside.