Explain the Python Operators with example in explained way.
Explain the Python Operators with example in explained way.
Ravi Vishwakarma is a dedicated Software Developer with a passion for crafting efficient and innovative solutions. With a keen eye for detail and years of experience, he excels in developing robust software systems that meet client needs. His expertise spans across multiple programming languages and technologies, making him a valuable asset in any software development project.
Anubhav Kumar
21-Sep-2025Example:
1. Arithmetic Operators
Used for basic math operations.
+10 + 515-10 - 55*10 * 550/10 / 52.0(always float)//10 // 33(drops decimal)%10 % 31**2 ** 38Example:
2. Comparison (Relational) Operators
Used to compare two values → return
TrueorFalse.==5 == 5!=5 != 3>5 > 3<5 < 3>=5 >= 5<=3 <= 5Example:
3. Assignment Operators
Used to assign values to variables (sometimes with an operation).
=x = 5+=x += 3x = x + 3-=x -= 2x = x - 2*=x *= 4x = x * 4/=x /= 2x = x / 2//=x //= 3x = x // 3%=x %= 2x = x % 2**=x **= 3x = x ** 3Example:
4. Logical Operators
Used for logical conditions (returns
True/False).and(x > 5 and y < 10)or(x > 5 or y < 10)notnot(x > 5)Example:
5. Identity Operators
Used to check if two objects are the same in memory.
isx is yis notx is not yExample:
6. Membership Operators
Used to check if a value is inside a sequence (list, tuple, string, etc.).
in"a" in "apple"not in"z" not in "apple"Example:
7. Bitwise Operators
Work at the bit level (binary representation).
&5 & 3^5 ^ 3~~5<<5 << 1>>5 >> 1Example:
Summary
+ - * / % // **)== != > < >= <=)= += -= ...)and, or, not)is, is not)in, not in)& | ^ ~ << >>)