Monday, 8 July 2019

Difference between identifier and variable

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():

Here, ‘area’ is still an identifier, But this time, the identifier ‘area’ is a name given to a ‘function’.


1 comment:

Files with Exception handling

#Ask the user to take two input integer values var a,b try:     a=int(input("enter any integer value:"))     b=int(input(&qu...