Operators and Operands in Python
In Python, operators are symbols (and some keywords) that perform computations; operands are the values they act on. Families include arithmetic, comparison, logical, assignment, membership, and identity.
Want to understand operators and operands in Python? Operators are the symbols that make values interact — add, compare, assign, check membership. The values they act on are the operands.
Until values sit alone, little happens. Programming begins when values combine. This page is the map of Python’s operator families: arithmetic, comparison, logical, assignment, membership, identity — plus a brief nod to bitwise. For a deeper treatment of and / or / not, see Logical Operators in Python.
What you will learn
By the end you can:
- Define operator vs operand
- Use arithmetic operators including
/,//,%, and** - Compare values with
==,!=,<,>,<=,>= - Combine conditions with
and,or,not(overview) - Update names with compound assignment (
+=,-=, …) - Check membership (
in) and identity (is) — and know they differ from==
This is an overview of operator families, not a deep dive into short-circuiting, truthiness, or bitwise math. Bitwise operators are named only; logical operators get a full leaf of their own.
Operators and operands — the action and the actors
Operators are special symbols (and a few keywords) that tell Python to perform a computation. Think of them as verbs. If values are nouns, operators are the actions that connect them. The values being acted on are called operands.
20 + 30+is the operator20and30are the operands
Not every operator is about math. Some compare. Some assign. Some check logic, membership, or identity. Below is each family.
Arithmetic operators
These perform numerical calculations.
| Operator | Meaning | Example | Result |
|---|---|---|---|
| + | Addition | 10 + 5 | 15 |
| - | Subtraction | 10 - 5 | 5 |
| * | Multiplication | 10 * 5 | 50 |
| / | True division | 10 / 4 | 2.5 |
| // | Floor division | 10 // 4 | 2 |
| % | Modulo (remainder) | 10 % 4 | 2 |
| ** | Exponentiation | 2 ** 3 | 8 |
True division vs floor division
In Python 3, / always returns a float — even when both operands are ints:
print(10 / 4) # 2.5
print(10 // 4) # 2// is floor division: it discards the fractional part toward negative infinity. For positive numbers that looks like “cut off the decimal” — it does not round to nearest.
Modulo (%)
Modulo gives the remainder after division:
print(10 % 4) # 2 because 10 = (4 * 2) + 2
print(7 % 2) # 1 → oddCommon uses: even/odd checks, cyclic counters, wrapping indices.
Comparison operators
These compare values and return True or False — boolean results you will later use in if statements.
| Operator | Meaning | Example |
|---|---|---|
| == | Equal to | 5 == 5 → True |
| != | Not equal | 5 != 3 → True |
| > | Greater than | 10 > 5 → True |
| < | Less than | 3 < 8 → True |
| >= | Greater or equal | 5 >= 5 → True |
| <= | Less or equal | 4 <= 10 → True |
Logical operators (overview)
Used to combine or invert conditions:
print(True and False) # False — both must be True
print(True or False) # True — at least one True
print(not True) # False — reverses the resultThat is enough for this map. Short-circuit evaluation, truthiness, and and vs & live on the dedicated page: Logical Operators in Python.
Assignment operators
Basic assignment stores a value under a name (see Variables in Python):
x = 5Compound assignment updates a variable in place:
x = 5
x += 3 # same as x = x + 3
x -= 2
x *= 4
x /= 2
x //= 3
x %= 2
x **= 2Membership operators
Check whether a value exists inside a sequence (list, string, and later other containers):
print(3 in [1, 2, 3]) # True
print(5 not in [1, 2, 3]) # True
print("a" in "cat") # TrueIdentity operators
These check whether two names refer to the same object in memory — not merely equal values:
a = [1, 2]
b = a
print(a is b) # True — same object
print(a is not b) # FalseBitwise operators (brief mention)
These work at the binary level: &, |, ^, ~, <<, >>. They show up in low-level work and some optimizations. You do not need them to start writing everyday Python — know they exist, then move on.
Big-picture summary
| Category | Purpose |
|---|---|
| Arithmetic | Mathematical operations |
| Comparison | Returns True / False |
| Logical | Combines conditions |
| Assignment | Assigns and updates values |
| Membership | Checks presence in a sequence |
| Identity | Checks memory identity |
| Bitwise | Operates at the binary level |
Operators are not just symbols. They decide how values combine, how logic flows, and how programs behave. Once they click, you start thinking in expressions — not only in isolated statements.
Common mistakes
- Using
=when you meant== - Expecting
/to return an int (it returns a float in Python 3) - Confusing
//with rounding - Treating
islike== - Using bitwise
&/|when you meant logicaland/or
Common questions
What are operators and operands in Python?
Operators are symbols or keywords that perform a computation. Operands are the values those operators act on. In 20 + 30, + is the operator and 20 and 30 are the operands.
What is the difference between / and // in Python?
In Python 3, / is true division and always returns a float (10 / 4 is 2.5). // is floor division and discards the fractional part toward negative infinity (10 // 4 is 2).
What does the % operator do in Python?
The % operator returns the remainder after division. For example, 10 % 4 is 2 because 10 = (4 × 2) + 2. It is often used for even/odd checks and cyclic counters.
What is the difference between == and = in Python?
== checks whether two values are equal and returns True or False. = assigns a value to a name. They are not interchangeable.
What is the difference between == and is in Python?
== compares values for equality. is checks whether two names refer to the same object in memory. Equal values are not always the same object.
What are membership operators in Python?
Membership operators are in and not in. They test whether a value appears in a sequence such as a list or string — for example, 3 in [1, 2, 3] is True.
Explore
Related topics
Keep going — these sit next to this concept in a real learning path.
Logical Operators in Python
Deep dive on and, or, not — short-circuit and truthiness.
Variables in Python
Names and assignment — where compound operators write back.
Types, Values, and Errors in Python
What values are before operators combine them.
Comments in Python
Annotate tricky expressions with useful # notes.
Statements vs Expressions in Python
REPL vs script — expressions produce values, statements act.
Order of Operations in Python
PEMDAS, precedence, parentheses, and left-to-right ties.
Data Types in Python
int, float, str, bool, list, tuple, dict, set — the full map.
Strings in Python
Indexing, slicing, immutability, and string methods.
Lists in Python
Mutability, list methods, map/filter/reduce, and the aliasing trap.
Python course hub
All free Python explainers and the path into Agentic practice.
Comparison Operators in Python
==, !=, <, >, and combining conditions with and/or/not.