x = 3
x += 3 is the same as x = x + 3
x *= 3 is the same as x = x * 3
x /= 3 is the same as x = x / 3 and so on.
These are all assignment operators.
3. Python Logical Operators
Python logical operators can be used within a statement to combine conditional statements. For example:
a > 1 and a < 3 returns True if ‘a’ contains a value that is more than 1 and less than 3.
a < 1 or a > 3 returns True if ‘a’ contains a value that is less than 1 or more than 3.
not(a > 1 and a < 3) returns True if ‘a’ contains a value that is less than 1 or more than 3.
4. Python Comparison Operators
We can use Python comparison operators to compare two values. For example,
a == b compares whether a and b contain the same value
a < b compares whether a is less than b
a > b compares whether a is greater than b
a != b compares whether a contains a value that is different from b
Similarly, a >= b compares whether a is greater than or equal to b and so on.
5. Python Bitwise Operators
Python bitwise operators are used to perform bitwise operations on operands. For example,
a | b performs a bitwise or operation between a and b
a & b performs a bitwise and operation between a and b
~a inverts all bits of a
a ^ b performs a bitwise xor operation between a and b
a << 2 left shifts the value of a by 2 bits and the rightmost 2 bits are filled with zeros
a >> 2 right shifts the value of a by 2 bits and the leftmost 2 bits are filled with zeros








































0 Comments