Some text some message..
Back 4. 🧮 Operators in Python — Detailed Explanation 19 Jun, 2025

Operators in Python are symbols or keywords that perform operations on variables and values. Python supports many types of operators for different tasks


🔹 1. Arithmetic Operators

Used for basic mathematical operations.

Operator Description Example Result
+ Addition 2 + 3 5
- Subtraction 5 - 2 3
* Multiplication 3 * 4 12
/ Division (float) 10 / 3 3.33
// Floor Division 10 // 3 3
% Modulus (remainder) 10 % 3 1
** Exponentiation 2 ** 3 8

🔹 2. Comparison (Relational) Operators

Compare two values and return True or False.

Operator Description Example Result
== Equal to 5 == 5 True
!= Not equal to 5 != 3 True
> Greater than 5 > 3 True
< Less than 3 < 5 True
>= Greater or equal 5 >= 5 True
<= Less or equal 3 <= 5 True

🔹 3. Assignment Operators

Used to assign values to variables.

Operator Description Example
= Assign x = 10
+= Add and assign x += 2
-= Subtract and assign x -= 1
*= Multiply and assign x *= 5
/= Divide and assign x /= 3
//= Floor divide and assign x //= 2
%= Modulus and assign x %= 4
**= Exponent and assign x **= 2

🔹 4. Logical Operators

Used to combine conditional statements.

Operator Description Example Result
and True if both are true x > 5 and x < 10 True
or True if one is true x > 5 or x == 2 True
not Reverse the result not(x > 5) False

🔹 5. Bitwise Operators

Used to perform bit-level operations.

Operator Description Example
& AND 5 & 31
` ` OR
^ XOR 5 ^ 36
~ NOT ~5-6
<< Left Shift 5 << 110
>> Right Shift 5 >> 12

🔹 6. Membership Operators

Used to test whether a value exists in a sequence (like list, tuple, string).

Operator Description Example Result
in True if present 'a' in 'apple' True
not in True if not present 'x' not in 'apple' True

🔹 7. Identity Operators

Compare memory locations of objects.

Operator       Description



Example Result
is   
  Same object?



 x is y True
is not
  Not same object?



 x is not y True