Python Progamming/Basics of Python Language

Python Tokens

Updated on January 12, 2026
1 min read

Tokens in Python programming

In Python, tokens are the basic pieces that form a program. The interpreter reads your code by breaking it into these pieces and using them to understand what the program should do. Without tokens, Python would not be able to process or run any code.

Types of Python Tokens

There are 6 types of tokens in Python:

1. Keywords

Keywords are reserved words with predefined meaning in Python. They cannot be used as variable names.

Examples:

 ifelsewhilefordefreturnTrueFalseNoneclassimport

2. Identifiers

Identifiers are names given to variables, functions, classes, and objects.

Rules:

  • Must start with a letter or underscore
  • Can contain letters, digits, and underscore
  • Cannot be a keyword
  • No spaces allowed

Examples:

 total_countsum1studentName

3. Constants

Constants are fixed values that do not change during program execution.

Types of constants:

    • Integer constant: 10-25
    • Floating constant: 3.142.5
    • String constant: "Hello""Python"
    • Boolean constant: TrueFalse

4. Operators

Operators are symbols used to perform operations on variables and values.

Types:

    • Arithmetic: + - * / %
    • Relational: > < >= <= == !=
    • Logical: and or not
    • Assignment: = += -=
    • Comparison: == !=

5. Delimiters (Special Symbols)

Delimiters help define the structure and syntax of Python programs.

Examples:

 ( ) [ ] { } : , . =

6. Strings

A string is a sequence of characters enclosed in single or double quotes.

Example:

 "Python Programming"

 'Hello World'

Example Showing Python Tokens

total = 10 + 20

Tokens used:

TokenType
totalIdentifier
=Operator
10, 20Constants
+Operator

Important Points

  • Tokens are the basic building blocks of a Python program
  • The Python interpreter reads programs token by token
  • Understanding tokens makes it easier to learn Python syntax and avoid errors
Python Tokens | Python Progamming | Learn Syntax