An arithmetic operator takes two operands as input, performs a calculation and returns the result.
Consider the expression, <b>“a = 2 + 3”</b>. Here, `2` and `3` are the <i>operands</i> and `+` is the <i>arithmetic operator</i>. The result of the operation is stored in the variable a.
<tablestyle="width:100%">
<tr>
<th>Operator</th>
<th>Description</th>
<th>Usage</th>
</tr>
<tr>
<tdalign="center">+</td>
<td>Performs Addition on the operands</td>
<td>12 + 3 = 15</td>
</tr>
<tr>
<tdalign="center">-</td>
<td>Performs Subtraction on the operands. <br>Subtracts the right operand from the left operand</td>
<td>12 - 3 = 9</td>
</tr>
<tr>
<tdalign="center">*</td>
<td>Performs Multiplication on the operands</td>
<td>12 * 3 = 36</td>
</tr>
<tr>
<tdalign="center">/</td>
<td>Performs Division on the operands. <br>Divides the left operand by the right operand</td>
<td>Performs a Modulus on the operands. <br>Returns the remainder obtained while dividing the left operand by the right operand</td>
<td>16 % 3 = 1</td>
</tr>
<tr>
<tdalign="center">**</td>
<td>Performs an Exponentiation operation. <br>The left operand is raised to the power of right operand</td>
<td>12 ** 3 = 1728</td>
</tr>
<tr>
<tdalign="center">//</td>
<td>Performs a Floor Division operation. <br>Returns the integral part of the quotient obtained after diving the left operand by the right operand</td>
<td>18 // 5 = 3</td>
</tr>
</table>
Note: To get the result in floating type, one of the operands must also be of float type.
A comparison or relational operator is used to compare two operands to decide a relation between them. It returns a boolean value based on the condition.
An assignment operator is used to assign values to a variable. This is usually combined with other operators (like arithmetic, bitwise) where the operation is performed on the operands and the result is assigned to the left operand.
Consider the following examples,
<br>
<b>a = 18</b>. Here `=` is an assignment operator, and the result is stored in variable a.
<br>
<b>a += 10</b>. Here `+=` is an assignment operator, and the result is stored in variable a. This is same as a = a + 10.
<tablestyle="width:100%">
<tr>
<th>Operator</th>
<th>Usage</th>
</tr>
<tr>
<tdalign="center">=</td>
<td>a = 5. The value 5 is assigned to the variable a</td>
</tr>
<tr>
<tdalign="center">+=</td>
<td>a += 5 is equivalent to a = a + 5</td>
</tr>
<tr>
<tdalign="center">-=</td>
<td>a -= 5 is equivalent to a = a - 5</td>
</tr>
<tr>
<tdalign="center">*=</td>
<td>a *= 3 is equivalent to a = a * 3</td>
</tr>
<tr>
<tdalign="center">/=</td>
<td>a /= 3 is equivalent to a = a / 3</td>
</tr>
<tr>
<tdalign="center">%=</td>
<td>a %= 3 is equivalent to a = a % 3</td>
</tr>
<tr>
<tdalign="center">**=</td>
<td>a **= 3 is equivalent to a = a ** 3</td>
</tr>
<tr>
<tdalign="center">//=</td>
<td>a //= 3 is equivalent to a = a // 3</td>
</tr>
<tr>
<tdalign="center">&=</td>
<td>a &= 3 is equivalent to a = a & 3</td>
</tr>
<tr>
<tdalign="center">|=</td>
<td>a |= 3 is equivalent to a = a | 3</td>
</tr>
<tr>
<tdalign="center">^=</td>
<td>a ^= 3 is equivalent to a = a ^ 3</td>
</tr>
<tr>
<tdalign="center">>>=</td>
<td>a >>= 3 is equivalent to a = a >> 3</td>
</tr>
<tr>
<tdalign="center"><<=</td>
<td>a <<= 3 is equivalent to a = a <<3</td>
</tr>
</table>
#### Logical Operators
A logical operator is used to make a decision based on multiple conditions. The logical operators used in Python are
`and`, `or` and `not`
<tablestyle="width:100%">
<tr>
<th>Operator</th>
<th>Description</th>
<th>Usage</th>
</tr>
<tr>
<tdalign="center">and</td>
<td>Returns True if both the operands are True<br>Returns False otherwise</td>
<td>a and b</td>
</tr>
<tr>
<tdalign="center">or</td>
<td>Returns True if any one of the operands are True<br>Returns False otherwise</td>
<td>a or b</td>
</tr>
<tr>
<tdalign="center">not</td>
<td>Returns True if the operand is False<br>Returns False otherwise</td>
<td>not a</td>
</tr>
<tr>
</table>
#### Membership Operators
A membership operator is used to identify membership in any sequence (lists, strings, tuples).
<br>`in` and `not in` are membership operators
<br>`in` returns True if the specified value is found in the sequence. Returns False otherwise.
<br>`not in` returns True if the specified value is not found in the sequence. Returns False otherwise.
###### Example Usage
```py
a = [1,2,3,4,5]
#Is 3 in the list a?
print 3 in a # prints True
#Is 12 not in list a?
print 12 not in a # prints True
str = "Hello World"
#Does the string str contain World?
print "World" in str # prints True
#Does the string str contain world? (note: case sensitive)
print "world" in str # prints False
print "code" not in str # prints True
```
#### Identity Operators
An identity operator is used to check if two variables share the same memory location.
<br>`is` and `is not` are identity operators
<br>`is` returns True if the operands refer to the same object. Returns False otherwise.
<br>`is not` returns True if the operands do not refer to the same object. Returns False otherwise.
Please note that two values when equal, need not imply they are identical.