Identifiers

In Python, keywords are predefined and reserved words with specific meanings. The syntax of the code is defined by keywords. The keyword can't be used as a variable name, function name, or identifier. Except for True and False, all keywords in Python are written in lower case. Let's have a look at each of the 33 keywords in Python 3.7 one by one.

Identifiers: An identifiers in python is a name that is used to identify a variable, function, class, module, or other type of object. The identifier is made up of a series of digits and underscores. The identification should begin with a letter or an Underscore and then be followed by a digit. A-Z or a-z, an UnderScore (_), and a digit are the characters (0-9). Special characters (#, @, $, percent,!) should not be used in identifiers.

Rules for writing identifiers

  1. Identifiers can be a combination of letters in lowercase (a to z) or uppercase (A to Z) or digits (0 to 9) or an underscore _. Names like myClassvar_1 and print_this_to_screen, all are valid example.
  2. An identifier cannot start with a digit. 1variable is invalid, but variable1 is a valid name.
  3. Keywords cannot be used as identifiers.
    global = 1
    Output
      File "<interactive input>", line 1
        global = 1
               ^
    SyntaxError: invalid syntax
  4. We cannot use special symbols like !@#$% etc. in our identifier.
    a@ = 0

    Output
      File "<interactive input>", line 1
        a@ = 0
         ^
    SyntaxError: invalid syntax
  5. An identifier can be of any length.

Comments

Popular posts from this blog

Unleashing Creativity: The Latest Frontier of Animation AI

Tanh Activation Function

Unveiling the Hidden Gems: Exploring Data Mining Functionality