Identifiers and Reversed Words

 Identifiers and Reversed Words

                    A Python Identifier is a name that is given to a function, class, variables, module, or other objects that will be used in a Python program. All the entities which are used in Python should be appropriately named or identified as they will form part of the program. 

simplepycoder.identifiers_reversed word

Identifiers

                    Identifiers are names that are given to different program elements, such as variables, functions, lists, etc. Identifiers are described by the following lexical definitions:

  • letters         -   lowercase  / uppercase
  • lowercase   -   "a"...."z"
  • uppercase   -   "A"......"Z"
  • digits          -   "0"....."9"

Rules for naming an identifier

  • An identifier must be a combination of uppercase letters, lowercase letters, underscores, and digits (0-9).                   
                    Example: my_var, var1, myvar.
  •  Special characters such as %, @, &, and * are not allowed within identifiers.                    
                    Example: my@var, var! is not valid.
  •  An identifier should not begin with a number.                   
                     Example: 1var, 1_var is not valid.
  •  Python is a case-sensitive language and this behavior extends to identifiers.                   
                     Example: VAR, var, Var are different variables.    
            But it sometimes creates confusion while reading the program and debugging
  •  Python keywords cannot be used as identifiers.                        
                    Example: class, break is not allowed.
  • We can use underscores to separate multiple words in identifiers.
                    Example: my_var.
  • Class identifiers begin with an uppercase letter, but the rest of the identifiers begin in lowercase.
                    Example: MyClass - class identifier   myvar - other identifier
  • Starting an identifier with a single leading underscore indicates that the identifier is private.
                    Example: _myvar
  • Starting an identifier with two leading underscores indicates a strongly private identifier.
                    Example: __myvar
  • If the identifier also ends with two trailing underscores, the identifier is a language-defined special name.
                    Example: myvar__

Keywords

                    Keywords are an essential part of a language definition. They implement specific features of the languages. Keywords have standard and predefined meanings in Python language. Which cannot be changed and they are the basic blocks for program statements.
                    In Python, only three keywords start in Uppercase they are True, False, None. All other keywords start in lowercase.

Keywords of Python                         

async

global

True

and

import

False

as

in

None

assert

is

exec

break

lambda

finally

class

not

for

continue

or

from

def

pass

try

elif

print

while

if

raise

with

await

del

else

except

return

yield

0/Post a Comment/Comments

Previous Post Next Post