Python identifier



Python Identifiers

Python  Identifier is the name we give to identify a variable, function, class, module or other object.

Rules to Define an Identifier

 1. It should not start with a number but after starting it with a valid symbol you use number happily.

                        1num = 10    (Invalid)
                         num1 = 10    (valid)

2. It can never be a keyword.
                      True = 10 (Invalid because True is predefined word)
                      TRUE = 10   (Valid)

3. Identifiers are case sensitive.

                     num = 10
                     NUM = 20
                     nUM = 30
                     Num = 40   (All variable are valid and different)

4. It can not contain any special symbol or hidden symbol.
                      num 1 = 10 (Invalid because of hidden symbol(space)
                      num$1 = 10  (Invalid becasue of special symbol($)

5. It can contain only a single special symbol that is _.
                      num_1   (Valid)

Python Keywords

 Python has a set of predefined words which  you can use but can not alter.

Note : There are total 33 keywords available in python


Post a Comment

Post a Comment (0)