Identifier and Keywords of python programming

Identifiers:

Identifiers in a Python programming, it is simply a name given to identify the variable, function, module or any other object used in the Python program. In Python programing language, we can use name as identifier using an upper case letters and lowercase letters (A-Z or a-z) as well as (0-9) numbers or underscore. Python does not allow punctuation characters such as @, $, and % within name of the identifiers.

Note: Python is case sensitive programming language, therefore fname and Fname are the two different identifiers.

Rules:

  1. They must consist of only letters, digits, or underscore. No other special character is allowed.
  2. An identifier cannot begin with a number.
  3. We cannot use special symbols in the name of identifier.
  4. We cannot use a keyword as name of an identifier.
  5. Class names start with an uppercase letter and all other identifiers with a lowercase letter.
  6. Starting an identifier with a single leading underscore indicates, that an identifier is to be private.
  7. Starting an identifier with two leading underscores indicates,  a strongly private identifier.

For Example: Write a program to demonstrate the use identifier. 

# this is example of addition of two numbers
x =55   # here x and y  is an identifier
y=35
z=x+y #here z is an identifier
print("Total Value is:",z)

Output :

Keywords: Keyword are also known as reserved or predefined word.  In Python programming some words are used as special words. They have meaning already explained to the python compiler. These words cannot be used as any identifier, because they assign a newest meaning to the keyword. They are not allowed by the python. These words are special and they are used to define the structure of python programs and statements. These are following keyword used in python-

 

and

del

global

not

with

as

elif

if

or

yield

assert

else

import

pass

break

except

in

raise

class

finally

is

return

continue

for

lambda

try

def

from

nonlocal

while


Comments