Identifiers in Python


Lets take looks on Identifiers and Operators mostly used in Python script.

Variable names and Identifiers in Python are similar to those in many other languages they will start with letter (A-Z or a-z) or an underscore(_).  Their length is limited only by your eagerness to type, and they are case-sensitive like kalgyan and Kalgyan are two different identifiers.  Regardless of length, choose identifiers that are meaningful.

Lets take simple valid and invalid Identifiers as example:
_2 # Technically valid, but not a good idea

7Index # Invalid, starts with a number
won’t_work # Invalid due to apostrophe character

There are few other identifier with special meaning
_name—Not imported by “from x import *”
__name__—System name
__name—Private class member

When we are running the Python interpreter in interactive mode, a single underscore character(__ is a special identifier that holds that result of the last expression evaluated this especially handy when you are using Python as destop calacuator:
>>> “Hello”
>>> _
>>> 5 + 2
>>> _ * 2
>>> _ + 5

Reserved Words in Pyhton
Let see some of the reserved key words which are used in Pyhton script language used:
and           del      for     is     raise
assert        elif     from    lambda return
break        else      global  not    try
class        except    if      or     while
continue      exec     import  pass
def           finally  in      print
Now we will some of the Oprators which all are used in Python script:
-      !=     %     &     *     **    /     ^      |      ~
+      <      <<    <=    <>    ==    >      >=     >>

Post a Comment