Python Token

 

 Python tokens 

  1. keywords
  2. Identifier/Variables
  3. Operators
  4. Delimiters
  5. Literals

  • Literals:
 Literal is a raw data given in a variable or constant.  In python types of literals - String literals: sequence of characters in quotes. 

Numeric literals: integer, float and complex numbers. 

Boolean literals: represents true or false .

Literal collections: lists, tuple, dictionary, set.

Special literal: None, is a null variable.

  • Keywords:
 These are reserved words with special meaning and purpose.They are used only for the intended purpose. 

Note: We cannot use a keyword as a variable name, function name or as any other identifier name. 

Python 2 has 32 keywords while Python 3.5 has 33 keywords(because nonlocal was added). In Python 3.7, async and await were added as keywords, resulting in a total of 35 keywords in Python 3.7.

  • Identifiers: 

Name of variable, function, class or module. if it starts with one underscore means it is private if it starts with starts and ends with 2 underscores then the identifier is a language defined special name. For example: Docstring becomes __doc__ a special attribute of an object.

  • Operator:

operators are special symbols which represent computation. They are applied on operands which can be values or variables. Same operator can behave differently on different data types. python supports the following operators 1
arithmetic operators                       [ /, *, +, -, %, // ] 
2 bitwise operators                         [ |, ^, ~, <<, >>] 
bitwise or, bitwise exclusive or, bitwise complement, Left shift, Right Shift. 
3 comparison/relational operators   [>, <, >=, <=, ==,  !=] 
4 logical operators                            [and, or, not] 
5 assignment operator                      [=, +=, -=, //=] 
6 unary operators.

  • Delimiter
Delimiters are special symbols that perform a special role in python like grouping, punctuation and assignment. Python uses the following symbols and symbol combination as delimiter.

Post a Comment

0 Comments