Identifier(Names)
Today we will be talking about Identifiers(Names) which is also a type of Tokens.
Identifiers are fundamental building blocks of a program and are used as the general terminology for the names given to different parts of the program viz. variables, objects, classes, functions, lists, dictionaries, etc. Identifier forming rules of Python are being specified below:
- An Identifier is an arbitrarily long sequence of letters and digits.
- The first character must be a letter; the underscore(_)counts as a letter.
- Upper and lower case letters are different. All characters are different.
- The digits 0 through 9 can be part of the identifier except for the first character.
- Identifiers are unlimited in length. Case is significant i.e., Python is case sensitive as it treats upper and lower case characters differently.
- An identifier must not be a keyword of Python.
- An identifier cannot contain any special character except for Underscore(_).
Rules to write an Identifiers(Names):
- Identifiers can be combination of letters in lowercase (a to z ) or uppercase (A to Z) or an underscore (_). Names like myschool, stud_1, and print_this are all examples of valid Identifiers.
- An Identifier cannot start with a digit.
- Keywords cannot be used as Identifier.
- We cannot use Symbols like @< $, %, &, ! etc. in our Identifier.
- Identifier can be of any Length.
Things to remember that, Python is case sensitive language, that is it will treat VARIABLE and variable differently as one of them is an Uppercase and the other is a Lowercase Character.
No comments:
Post a Comment
If you have any doubts, please do let me Know.