0% found this document useful (0 votes)
9 views

Variable in Python

Age = 20 is an example of using the assignment operator to assign the value 20 to the variable named Age. Variables in Python allow programs to store and work with data values by using variable names as labels to refer to stored values. There are two types of variables in Python: local variables, which are only accessible inside the function they are declared in, and global variables, which can be accessed throughout the entire program.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Variable in Python

Age = 20 is an example of using the assignment operator to assign the value 20 to the variable named Age. Variables in Python allow programs to store and work with data values by using variable names as labels to refer to stored values. There are two types of variables in Python: local variables, which are only accessible inside the function they are declared in, and global variables, which can be accessed throughout the entire program.
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Variables in Python

Assignment operator

Age = 20

Variable Name Value


Variables in Python
Python variables are simply containers for storing data
values. It's like a label that you can use to store and retrieve
values. Variables allow you to work with data in your programs.

Types:

• There are 2 types of variable in python:


• Local Variable
Global Scope
• Global Variable
global_var=10
Local Scope

def fun():
local_var=10
• Local Variable
• A variable declared inside a function is a local variable.
• It is only accessible within that function.

Code:

Output :
• Global Variable
• A variable declared outside of any function or block is a global
variable.
• It is accessible throughout the entire program.

Code:

Output :

You might also like