2.13OPERATORS IN PYTHON
Operators are used for performing operations on variables and values.
Python divides the operators into the following groups:
•Arithmetic operators
•Assignment operators
•Comparison operators
•Logical operators
•Identity operators
•Membership operators
•Bitwise operators
Python Arithmetic Operators
Arithmetic operators are used with numeric values to perform common mathematical operations.
Table 2.1 Common mathematical operations
| Operator | Name | Example |
| + | Addition | x + y |
| − | Subtraction | x − y |
| ∗ | Multiplication | x ∗ y |
| / | Division | x / y |
| % | Modulus | x % y |
| ∗∗ | Exponentiation | x ∗∗ y |
| // | Floor division | x // y |
Python Assignment Operators
Assignment operators are used for assigning values to variables.
Table 2.2 Assignment operators
| Operator | Example | Same As |
| = | x = 5 | x = 5 |
| += | x += 3 | x = x + 3 |
| −= | x −= 3 | x = x − 3 |
| ∗= | x ∗= 3 | x = x ∗3 |
| /... |