Python learning resources
Beginner to advanced Python guides, cheatsheets, books and projects.
For data science, backend and automation.
Join π https://rebrand.ly/bigdatachannels
DMCA: @disclosure_bds
Contact: @mldatascientist
Post #415
926
Python Variable Types: Local & Global
There are two types of variables in Python, Global variable and Local variable. When you want to use the same variable for rest of your program or module you declare it as a global variable, while if you want to use the variable in a specific function or method, you use a local variable while Python variable declaration.
Letβs understand this Python variable types with the difference between local and global variables in the below program.
Let us define variable in Python where the variable βfβ is global in scope and is assigned value 101 which is printed in output
Variable f is again declared in function and assumes local scope. It is assigned value βI am learning Python.β which is printed out as an output. This Python declare variable is different from the global variable βfβ defined earlier
Once the function call is over, the local variable f is destroyed. At line 12, when we again, print the value of βfβ is it displays the value of global variable f=101
π Read Online
#Python #python_3
βββββββββββββ
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
There are two types of variables in Python, Global variable and Local variable. When you want to use the same variable for rest of your program or module you declare it as a global variable, while if you want to use the variable in a specific function or method, you use a local variable while Python variable declaration.
Letβs understand this Python variable types with the difference between local and global variables in the below program.
Let us define variable in Python where the variable βfβ is global in scope and is assigned value 101 which is printed in output
Variable f is again declared in function and assumes local scope. It is assigned value βI am learning Python.β which is printed out as an output. This Python declare variable is different from the global variable βfβ defined earlier
Once the function call is over, the local variable f is destroyed. At line 12, when we again, print the value of βfβ is it displays the value of global variable f=101
π Read Online
#Python #python_3
βββββββββββββ
Join @python_bds for more cool data science materials.
*This channel belongs to @bigdataspecialist group
- π 2





