top of page

Global Variables in Python

Updated: Apr 19, 2023

The global variables can be used throughout the program.





a = 100

def fun1():
    print('Number is:', a)
    
fun1()


If the global variable is accessed inside a function and its value is changed inside a function, then it is limited to that function itself.



def fun2():
    a = 200
    print("Fun2 number is:", a)
    
fun2()
print(a)

The link to the Github repository is here .

Subscribe to get all the updates

© 2025 Metric Coders. All Rights Reserved

bottom of page