#20 - Variable Scope in Python

Publié le: 13 novembre 2020
sur la chaîne: Tech Vitals
301
9

Learn about variable scope in Python. Variable scope simply defines the scope of variables i.e. where can we access or use the variables based on their scopes or based on the location where they are defined.
We have following variable scopes:
L == Local
E == Enclosing
G == Global
B == Built-in

When we create a variable inside a function, that variable is called local variable of that function which is only accessible within that function.
When we create a nested function inside a function, all the variables that are defined inside the outer function i.e. all the variables that are defined outside the inner or nested function, those variables will be the enclosing variables of inner function.
When we create a variable outside a function, that variable is called global function which is accessible anywhere in the program OR which is accessible globally.
Built-in variables are those which are pre-defined in the Python itself like print, max, min, count, global, nonlocal etc.

Facebook:   / techvitals  


Sur cette page du site, vous pouvez voir la vidéo en ligne #20 - Variable Scope in Python durée heure minute seconde en bonne qualité , qui a été Téléchargé par l'utilisateur Tech Vitals 13 novembre 2020, Partagez le lien avec vos amis et connaissances, sur youtube cette vidéo a déjà été regardée 301 fois et il a aimé 9 téléspectateurs. Bon visionnage!