Local Scope Variable :

def myfunc():
    x = 300
    print(x)

myfunc()

Output :

300

Function Inside Function Accessing Local Variable :

def myfunc():
    x = 300
    def myinnerfunc():
        print(x)
    myinnerfunc()

myfunc()

Output :

300

Global Scope Variable :

x = 300

def myfunc():
    print(x)

myfunc()
print(x)

Output :

300
300

Local vs Global Variable with Same Name :

x = 300

def myfunc():
    x = 200
    print(x)

myfunc()
print(x)

Output :

200
300

Creating Global Variable Using global Keyword :

def myfunc():
    global x
    x = 300

myfunc()
print(x)

Output :

300

Modify Global Variable Using global Keyword :

x = 300

def myfunc():
    global x
    x = 200

myfunc()
print(x)

Output :

200