This content originally appeared on DEV Community and was authored by CodeExampler
In this Technician’s Python article, we are getting to study identifier in python. They're the essential building blocks of Python and that we use them everywhere while writing programs. So, it’s important to know everything about them.
We will see the principles to define identifiers and every one of the simplest practices following while defining Python identifiers. Let’s start with the definition of identifiers.
Q- What is Python Identifier?
“An identifier may be a name given to an entity”.
In very simple words, an identifier may be a user-defined name to represent the essential building blocks of Python. It is often a variable, a function, a class, a module, or another object.
Naming Rules for Identifiers
Now you recognize what exactly identifiers are. So, how can we use them? We can’t use anything, there are some certain rules to stay in mind that we must follow while naming identifiers.
- The Python identifier is formed with a mixture of lowercase or uppercase letters, digits, or an underscore.
These are the valid characters.
Lowercase letters (a to z)
Uppercase letters (A to Z)
Digits (0 to 9)
Underscore (_)
Examples of a legitimate identifier:
num1
FLAG
get_user_name
userDetails
_1234
- An identifier cannot start with a digit. If we create an identifier that starts with a digit then we'll get a software error.
This content originally appeared on DEV Community and was authored by CodeExampler
CodeExampler | Sciencx (2021-09-07T08:54:36+00:00) Identifier in Python by CodeExampler Website. Retrieved from https://www.scien.cx/2021/09/07/identifier-in-python-by-codeexampler-website/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.