Identifiers in Python

In this post am taking you through the one of the very basic python or any other language concept– Identifiers in Python which is quite simple but still sometimes can twist your mind like never before. So go through it and let’s make it easy for you.
Before going any further, I would say take a look at our Python Chapters.
(It will help you in grasping some more basic PY concepts in very detail.)
Identifiers
- An identifier is a name given to the entities such as– variable, functions, objects etc.
- Can have some other properties too.
- They are case sensitive.
(So, ‘A’ and ‘a’ both will be considered different.)
Analogy
A person / animal / place etc. can be defined as a variable, as I said earlier. Plus, every individual has a name, this name is called Identifier for a particular variable.
Variable (Whole) |
Identifier (Particular) |
Person |
Abhishek |
Animal |
Kiwi |
How to Define Identifiers?
- They are case sensitive.
(So, ‘A’ and ‘a’ both will be considered different) - Can ONLY contain Letters, Numbers and Underscores.
- Can’t start with a number.
1x → Wrong
x1 → Right
- Can’t be same as Python Keywords. i.e.
del = 'Some Operation' True = 5
The whole thing will show you a Syntax error. Here’s a list of keywords in python. Just take a look at them for just the sake of syntax error.
Note— (You don’t need to remember this table, you will automatically mesmerize them all as you code or practice.)
Example 1:
x = 5 or x = 'Hello!'
Explanation:
In both of the above statements, we had given a name to the expression on the left side of the ‘=’ sign, which is called an identifier. So, here ‘x’ is an identifier(name) for the variable.
Example 2:
X1 = 'GoodBye!'
Explanation:
In the above statements, we had given a name to the expression on the left side of the ‘=’ sign, which is called an identifier. So, here ‘X1’ is an identifier(name) for the variable.
So, that’s all from Identifiers in Python. I hope it helps.
Keep visiting for more PY stuffs. 💡 💡
That’s great explanation and well presented.
Hey Nikita,
Thanks for being a regular tweaker. Keep visiting for more on Python. Cheers! 🙂
Keep going.
Everyone would benefit from reading this post.
I have read some good stuff here. Definitely worth bookmarking for revisiting. I wonder how much effort you put to make such a magnificent informative site.
Hey man,
It’s all about passion. Meanwhile, thanks for your words. Cheers! 🙂