Difference between identifier and variable
Identifier
|
Variable
|
Definition:
The word ‘identifier’ clearly tells itself, an identifier is a name given to
an variable/function/class, which distinctly identifies a program at the time
of its execution.
|
Variable
is also an identifier, its name uniquely identifies itself in a program.
Here, the fundamental difference between an identifier and variable is that
an identifier is a “name given to entity(variable or function/class/file)” in
a program whereas, a variable is a “name given to memory location”, that is
used to hold value, which may get modified during program execution.
|
Identifier
is used to name a variable, function, class, object etc.
|
Variable
is used to name a memory location, which holds a value.
|
An
identifier is Created to give a unique name to an entity (Here entity means
variable or function or class).
|
Allots
a unique name to a particular memory location.
|
All
identifiers are not variable.
|
All
variables names are identifier.
|
Ex:
a=10
or
def
a():
print("Hi")
|
a=20
or
b=30
|
Let’s understand it with an example.
area=10
Here ‘area’ is an ‘identifier variable’. The identifier ‘area’ is a name
given to a ‘variable’ which will store a value 10. Now if ‘area’ weren’t a
variable, but a function, then
def area():
It 's an amazing and awesome blog
ReplyDeleteBest Python Training Online
Python Online Classes