Back to: Python Tutorial

**Operators**:

Python operators allow programmers to manipulate data or operands. Here are the types of operators supported by Python:

⦁ Arithmetic Operators

⦁ Assignment Operators

⦁ Relational or Comparison Operators

⦁ Logical Operators

⦁ Identity Operators

⦁ Bitwise Operators

⦁ Membership Operators

**Arithmetic Operators**:

Arithmetic Operators contain the following mathematical expression.

Addition, Subtraction, multiplication, and division are the most basic operators and invoked by entering the following expressions:

```
Addition:
>>>1+3
4
Subtraction:
>>>10-4
6
Multiplication:
>>>4*2
8
Division:
>>>10/2
5.0
Exponent
>>>2**3
8
Modulus
The modulus operator gives the remainder after performing division:
>>>17%5
2
```

Floor Division

Floor Division, on the other hand, returns the quotient after removing factorial numbers:

```
>>>17//5
3
Program that will compute the sales tax and tip on a restaurant meal.
Meal cost $65.50
Sales tax rate 6.6%
Tip 20% of meal +tax
```

```
program:
meal=65.50
tax=6.6/100
tip=20/100
meal=meal+meal*tax
total=meal*tip
meal=65.50
tax=6.6/100
tip=20/100
meal=meal+meal*tax
total=meal+meal*tip
>>>total
83.78760000
```

**Assignment Operators**:

these operators are useful when assigning values to variables:

**Relational or Comparison Operators**:

Relational operators evaluate values on the left and right side of the operators and return the relation as either True or False.

```
Examples:
>>>8==6+2
True
>>>6!=6
False
>>>-1>0
False
>>>7>=5
True
```

**Logical Operators**:

The following are logical operators:

```
Examples:
>>>(8>9)and(2<9)
False
>>>(2==2)or(9<20)
True
>>>not(8>2)
False
```

** Identity Operators **:

Identity Operators are used in Python to identifying the type of data that contain by a certain variable contain.

**is**: is operator return True if both the operator point at the same object

**is not:** is not operator returns True if both the variables does not point to the same object

**Bitwise Operator**:

These operators work bitwise on data. They perform different operation on bits of a data

** Membership Operators** :

Python has a membership operator that tests for membership in a sequence of such as strings, lists, or tuples.