Python Basic to Advance Series
Day 6 (Python Operators)
Python Basic to Advance Series
Day 6 (Python Operators)

Image Source: Workflow visualization of Python operators interact using math and logic.
What are Operators in Python?
In Python operators are essential for performing mathematical and logical operations on the values and variables. Each operator has its symbol which is known for specific task to perform like calculation, logic, comparisons and data manipulation.
Categories of Python Operators
- Mathematical/ Arithmetic Operators:
+(Addition): Adds two operands.-(Subtraction): Subtracts the right operand from the left.*(Multiplication): Multiplies two operands./(Division): Divides the left operand by the right (returns a float).%(Modulus): Returns the remainder of division.**(Exponentiation): Raises the left operand to the power of the right.//(Floor Division): Divides and rounds down to the nearest integer.
2. Comparison and Logical Operators
- These compare two values and return a Boolean result (
TrueorFalse)==(Equal): Checks if values are equal!=(Not Equal): Checks if values are different.>(Greater Than) /<(Less Than): Checks magnitude.>=(Greater Than or Equal) /<=(Less Than or Equal): Checks magnitude including equality. - Used to combine conditional statements.
and: ReturnsTrueonly if both operands are true.or: ReturnsTrueif at least one operand is true.not: Reverses the Boolean state (True becomes False).
3. Assignment Operators
- Used to assign values to variables. Compound operators perform an operation and assignment simultaneously.
=: Basic assignment (a = 10).+=,-=,*=,/=: Add, subtract, multiply, or divide then assign%=,**=,//=: Modulus, exponent, and floor division assignment.
4. Bitwise Operators
- Perform operations at the binary level on integers.
&(AND),|(OR),^(XOR): Bitwise logic.~(NOT): Inverts bits.<<(Left Shift) />>(Right Shift): Shifts bits left or right
5. Identity and Membership Operators
- Identity (
is,is not): Checks if two variables point to the same object in memory (not just equal values). - Membership (
in,not in): Checks if a value exists within a sequence (list, string, tuple, dictionary keys).
Operator Precedence
When multiple operators appear in an expression, Python evaluates them based on precedence (highest to lowest):
** (Exponentiation)
~, +, - (Unary plus, minus, NOT)
*, /, %, // (Multiplication, Division)
+, - (Addition, Subtraction)
<<, >> (Bitwise Shifts)
& (Bitwise AND)
^, | (Bitwise XOR, OR)
Comparison operators (<=, <, >, >=, ==, !=)
Assignment operators (=, +=, etc.)
Identity (is) and Membership (in)
Logical (not, and, or)
메타데이터
- post_id
- 6e59be59b0e1
- slug
- python-basic-to-advance-series-6e59be59b0e1
- url
- https://medium.com/@basnet.niraj86/python-basic-to-advance-series-6e59be59b0e1
- canonical_url
- https://medium.com/@basnet.niraj86/python-basic-to-advance-series-6e59be59b0e1
- author_url
- https://medium.com/@basnet.niraj86
- status
- ok
- fetched_at
- 2026-08-24 00:20:16