In this example we will show how to create global scoped variables in Python.
Source Code
var1 = 6
def my_func():
print(var1 + 2)
my_func()
# a variable created outside of a function is global, and can be used by anyone
print(var1)
Output:
8
6