Lesson 01
What Are Operators and Expressions?
Learn what an operator is, how expressions are formed, and the seven operator families using visual references and real Python examples.
What you'll learn
- What an operator is
- What an expression is
- The seven operator families
- Why Python has no
++operator
1. What is an operator?
An operator is a symbol that tells Python to perform an action on values, variables, or objects.
Visual analogy: calculator
Think of a calculator: the numbers already exist; the + button tells the calculator what action to perform. Python operators work the same way.
Python example
a = 10
b = 3
print(a + b)13How Python sees it
Operator =
+→ tells Python to add two values.
2. What is an expression?
An expression is a combination of values, variables, or objects connected by operators that Python can evaluate.
Visual flow
Code
a = 10
b = 3
result = a + b
print(result)The expression is a + b. The result is 13.
3. The seven operator families
Connect each family to a purpose — not just a symbol.
1. Arithmetic operators
Perform mathematical calculations.
10 + 3
10 * 3Think: calculator
2. Assignment operators
Store values inside variables.
age = 25
age += 1Think: put a value into a labeled box
3. Relational operators
Compare two values; result is True or False.
10 > 3Think: compare two sides of a scale
4. Logical operators
Combine multiple conditions.
age > 18 and score > 50Think: decision making
5. Bitwise operators
Work directly with binary representations of integers.
5 & 3Think: low-level bit patterns (hardware-style logic)
6. Membership operators
Check whether a value exists inside a collection.
"Y" in "PYTHON"Think: search inside
7. Identity operators
Check whether two names refer to the same object in memory.
x is yThink: same memory object, not just equal values
4. Operator mind map
This is the classification you will use throughout the rest of this module.
Later you will also see Python’s if ... else expression form (ternary) — it is not a separate symbol family like + or and, but it is the Python way to choose between two values.
5. Membership vs identity (most confusing pair)
Membership → “Is it inside?”
print("Y" in "PYTHON")TruePython searches inside the string "PYTHON".
Identity → “Is it the same object?”
x = [1, 2]
y = x
print(x is y)TrueBoth variables point to the same memory object, not just equal values.
Easy memory trick
| Operator | Meaning |
|---|---|
in |
Search inside a collection |
is |
Check identity (same object) |
6. What Python does not support
Python intentionally avoids some operators found in C, C++, Java, and C#.
Not supported (C / C++ / Java style)
a++
--b
x ? y : zThese produce syntax errors in Python.
Python alternatives
a += 1
b -= 1
y if x else zReadable, explicit syntax.
7. Interactive playground
Run the code in Try it in the playground at the bottom of this lesson. Identify which operator family each line uses.
Expected output
Expression a + b: 13
Relational: True
Logical: True
Membership: True
Identity (same object): TrueIdentify the family
| Code | Family |
|---|---|
a + b |
Arithmetic |
a > b |
Relational |
and |
Logical |
"Y" in "PYTHON" |
Membership |
x is y |
Identity |
Practice exercises
Exercise 1 — Write an arithmetic expression that multiplies 8 and 5, then adds 2:
# Your code here
print(8 * 5 + 2)Exercise 2 — Without looking above, write the seven operator families in order.
Exercise 3 — Predict before running:
a = 5
a++Invalid — a++ is not valid Python. Use a += 1 instead.
Quick knowledge check
-
What is an operator?
A symbol that performs an operation on values, variables, or objects. -
What is an expression?
Values, variables, or objects connected by operators that Python evaluates. -
Does Python support
++?
No. Use+= 1instead.
Summary cheat sheet
| Concept | Remember |
|---|---|
| Operator | A symbol that performs an action |
| Expression | Values connected by operators |
| Arithmetic | Calculator |
| Assignment | Store value |
| Relational | Compare values |
| Logical | Combine conditions |
| Bitwise | Binary operations |
| Membership | Search inside |
| Identity | Same object in memory |
Next lesson: Arithmetic Operators — +, -, *, /, //, %, ** with step-by-step examples.
Loading playground…