# Basic Operators in Python

Operators are used to manipulate variables and values by performing operations on them. They are an essential part of any programming language. Python has the following types of operators:

• Arithmetic operators
• Assignment operators
• Comparison operators
• Logical operators
• Identity operators
• Membership operators
• Bitwise operators

Let’s look at the details of these operator types one by one.

## Arithmetic operators

These are used to perform simple mathematical operations on numerals.

Note: Let’s assume x = 20 and y = 40 for examples.

## Assignment operators

These are used to assign values to variables.

## Comparison operators

These are used to compare two variables and are commonly used in while loops or conditionals.

Note: Let’s assume x = 20 and y = 40 for examples.

## Logical operators

Following logical operators are supported by Python:

Note: Let’s assume a = True and b = False for examples.

## Identity operators

These are used to compare the objects returning whether they are actually the same object with the same memory location.

## Membership operators

These are used to test if an element is present in a sequence (list, array, tuple) or not.

Note: Let’s assume p = 2 and q = [0, 2, 4, 6, 8] for examples.

## Bitwise operators

These operators work on bits and perform bit by bit operation on binary numbers.

Note: Let’s assume u = 0011 1100 and v = 0000 1101 for examples.

## Operator Precedence

The following table lists operators in the order of their precedence in Python: