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 .

1 view

Related Posts

How to Install and Run Ollama on macOS

Ollama is a powerful tool that allows you to run large language models locally on your Mac. This guide will walk you through the steps to...

bottom of page