Python Tokens

In this session i have discussed Tokens in Python .

A Token is a smallest individual unit in python program that is meaningfull to the interpreter . It can be classified as following .

1-Keywords (eg. if , for etc)

2-Identifiers (eg. name , x , y)

3-Constants (eg. 10 , 20)

4-Strings (eg. "total","Ram")

5-Punctuators (eg. [] , {})

6-Operators (eg. + , - / , *)

1-Keywords :

Keyword is a predefined or reserved word in python . You can not use the keyword as variable name .

We have already learned the keyword in details . Pls click on Keyword link for more info .

2-Identifiers :

Identifiers refers names such as variable , function , class etc in python .

Identifiers identifies the entities like variable , function , structure etc in python .

We have already discuss the identifier . Pls for more info click on Identifier link .

3-Constants :

Constants are the values assigned to variable in python program . It is also called literal . There are many types of literal given below .

3.1-String Literals .

3.2-Numeric Literals .

3.3-Boolean Literals .

3.4-Special Literals None .

3.4-Literal Collection .

3.1-String Literals :

The text enclosed in quotes forms a string literal in python. For example 'x' , 'name' , "name" are all string literal in python.

3.2-Numeric Literals :

It is represents numbers. int or integers are positive or negatice numbers with no decimal point. floats represents real numbers and are written with deciaml point dividing the integer and fractional parts.

3.3-Boolean Literals :

A boolean literal represent True or False values.

3.4-Special Literals None :

Python has one special literal, Which is None. The None literal is used to indicate absence of value. It is also used to indicate the end of list in python.

    OUTPUT : None


The String is represented by the sequence of character in pair of double quote marks like "hello" or single quote 'abc' or triple quote """abc""" etc


Punctuators are symbols that are used in programming languages to organize sentences structures , and indicate the rhythem and emphasis of expressions, statement, and program structure.

The most commonly used punctuators are as follows.

{}[]@,: etc.

We will discuss details in later.


An operator is a symbol that tells the compiler to perform a certain mathematical or logical manipulation. Operators are used in programs to manipulate data and variables . The value or variable is called the operand on which the operators perform action .

       print("Sum : %d"%(sum))  
    OUTPUT : Sum : 30

the + is operator . x and y is the operand .

We will discuss the operator details in next chapter .

Welcome to AndroidATPoint.

back image                     next image