Python Operators
VIDYA ACADEMY
Python Operators :-
- Arithmetic Operator.
- Assignment Operator.
- Comparison Operator.
- Logical Operator.
- Identity Operator.
- Membership Operator.
- Bitwise Operator.
- Python arithmetic operator :-
- Python assignment operator :-
- Python comparision operator :-
- Python logical operator :-
- Python identity operator :-
- Python membership operator :-
- Python bitwise operator :-
| 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 |
| Operator | Example | Same as |
|---|---|---|
| = | x = 5 | x = 5 |
| += | x += 3 | x = x + 3 |
| -= | x -= 3 | x = x - 3 |
| *= | x *= 3 | x = x * 3 |
| /= | x /= 3 | x = x / 3 |
| %= | x %= 3 | x = x % 3 |
| //= | x //= 3 | x = x // 3 |
| **= | x **= 3 | x = x ** 3 |
| &= | x &= 3 | x = x & 3 |
| |= | x |= 3 | x = x | 3 |
| ^= | x ^= 3 | x = x ^ 3 |
| >>= | x >>= 3 | x = x >> 3 |
| <<= | x <<= 3 | x = x << 3 |
| Operator | Name | Example |
|---|---|---|
| == | Equal | x == y |
| != | Not equal | x != y |
| > | Greater than | x > y |
| < | Lass than | x < y |
| >= | Greater than equal to | x >= y |
| <= | Less than equal to | x <= y |
| Operator | Description | Example |
|---|---|---|
| and | Return True it both statements are true |
x < 5 and x >10 |
| or | Retuens True if one of the statements is true |
x < 5 or x < 4 |
| not | Reverse the result, returns false if the result is true |
not ( x < 5 and x<10 ) |
Identity operators are use to compare the objects, not if they are equal,
but if they are actually the same object, with the same memory location.
| Operator | Description | Example |
|---|---|---|
| is | Return True if both variable are the same object |
x is y |
| is not | Return true is both variable are not the same object |
x is not y |
| Operator | Description | Example |
|---|---|---|
| in | Returns True if a sequence with the specified value is present in the object |
x in y |
| not in | Returns True if a sequence with the specified value is not present in the object |
x not in y |
| Operator | Name | Example |
|---|---|---|
| & | Bitwise and | x & y |
| | | Bitwise or | x | y |
| ~ | Bitwise not | ~x |
| ^ | Bitwise xor | x ^ y |
| >> | Bitwise right shift | x>> |
| << | Bitwise left shift | x<< |
टिप्पणियाँ
एक टिप्पणी भेजें
thank you