Types Of Python Variables:
The variable is a container that stores a data value in computer memory. Here we see two types of variables in Python.
1. LOCAL VARIABLE: -
Local variables are the variables that are declared inside the function and have scope within the function. Let's understand the following example.
![]() |
| Local Variable |
CLICK HERE TO KNOW ABOUT: WHAT IS VARIABLE IN PYTHON?
2. GLOBAL VARIABLE: -
Global variables can be used throughout the program, and its scope is in the entire program. We can use global variables inside or outside the function.
A variable declared outside the function is the global variable by default. Python provides the global keyword to use a global variable inside the function. If we don't use the global keyword, the function treats it as a local variable. Let's understand the following example.
![]() |
| Global Variable |
MULTI WORDS VARIABLE NAME:
Variable names with more than one word can be difficult to read. There are several techniques you can use to make them more readable-
1. CAMEL CASE: In the camel case, each word or abbreviation in the middle begins with a capital letter. There is no intervention of whitespace. For example - nameOfStudent, value Of Variable, etc.
![]() |
| CAMEL CASE |
![]() |
| PASCAL CASE |
3. SNAKE CASE: In the snake case, Words are separated by the underscore. For example - name_of_student, etc.
![]() |
| SNAKE CASE |
MULTIPLE ASSIGNMENT:
Python allows us to assign a value to multiple variables in a single statement, which is also known as multiple assignments.
We can apply multiple assignments in two ways, either by assigning a single value to multiple variables or assigning multiple values to multiple variables. Consider the following example.
1. ASSIGN SINGLE VALUE TO MULTIPLE VARIABLES:
![]() |
| SINGLE VALUE |







0 Comments