Python Mathematical Symbols- Complete Reference Guide

What This Guide Covers

You'll find every Python mathematical symbol explained here — operators, bitwise tricks, special functions, and the precedence rules that determine how expressions actually get evaluated. No filler. Just the symbols you need to write real code.

Basic Arithmetic Operators

These are the symbols you use every day for math in Python. Nothing fancy, but you need them memorized.

SymbolOperationExampleResult
+Addition5 + 38
-Subtraction10 - 46
*Multiplication6 * 742
/Division15 / 43.75
//Floor Division15 // 43
%Modulus (remainder)15 % 43
**Exponentiation2 ** 532

The // floor division operator trips people up. It doesn't round — it cuts off everything after the decimal point. 15 // 4 gives 3, not 3.75.

The % modulus operator returns the remainder. It's not just for math — it's how you check if a number is even or odd: number % 2 == 0 means even.

Comparison Operators

These return True or False. That's it. No ambiguity, no surprises.

SymbolMeaningExample
==Equal to5 == 5 → True
!=Not equal to5 != 3 → True
>Greater than7 > 5 → True
<Less than3 < 8 → True
>=Greater than or equal5 >= 5 → True
<=Less than or equal4 <= 9 → True

Common mistake: using = when you mean ==. The single equals assigns. The double equals compares. Mixing them up will silently break your code or throw an error, depending on context.

Logical Operators

These combine boolean values. Python gives you three: and, or, not.

Short-circuit evaluation applies here. With and, if the first value is False, Python skips the second check entirely. With or, if the first value is True, the second check gets skipped. This matters when your second check would cause an error.

Example that won't crash: x > 0 and 10 / x > 1. If x is 0, the first condition fails and division never happens.

Bitwise Operators

These operate on individual bits. You won't use them daily, but when you need them, you really need them — flag manipulation, color processing, low-level optimization.

SymbolOperationExample (4 & 8)
&Bitwise AND4 & 8 → 0
|Bitwise OR4 | 8 → 12
^Bitwise XOR4 ^ 8 → 12
~Bitwise NOT~4 → -5
<<Left shift4 << 1 → 8
>>Right shift4 >> 1 → 2

The ~ operator returns the bitwise complement. In practice, ~x equals -(x+1). That's worth memorizing if you're working with binary data.

Assignment Operators

These combine an operation with assignment in one step. Cleaner code, same result.

These work exactly like their two-step equivalents. x += 1 is identical to x = x + 1, just less typing.

Identity vs Membership Operators

Two operators that confuse beginners: is and in. They sound similar but do completely different things.

Identity: is / is not

Checks if two variables point to the same object in memory. Not the same value — the same object.

a = [1, 2, 3]
b = [1, 2, 3]
c = a

a == b  # True — same values
a is b  # False — different objects
a is c  # True — same object

Membership: in / not in

Checks if a value exists inside a collection (list, tuple, string, dictionary).

"cat" in ["dog", "cat", "bird"]  # True
"x" in "example"                 # True
4 in range(10)                   # True

For dictionaries, in checks keys, not values. "name" in {"name": "John", "age": 30} returns True. "John" in {"name": "John", "age": 30} returns False.

Math Module Constants and Functions

Python's built-in math module gives you constants and functions that go beyond basic operators.

Constants

Common Functions

Operator Precedence

When you stack operators, Python follows a specific order. Here's the hierarchy from highest to lowest priority:

PriorityOperators
1 (highest)** (exponentiation)
2+x, -x, ~x (unary)
3*, /, //, %
4+, -
5<<, >>
6&
7^
8|
9==, !=, >, <, >=, <=, is, is not, in, not in
10not
11 (lowest)and
12or

Left-to-right applies within the same priority level, except exponentiation which goes right-to-left. So 2 ** 3 ** 2 equals 2 ** 9 = 512, not 8 ** 2 = 64.

When in doubt, use parentheses. (a + b) * c is clearer than relying on precedence rules.

Getting Started: Practical Examples

Copy these patterns directly into your code.

Check if a number is even or odd

number = 42
if number % 2 == 0:
    print("even")
else:
    print("odd")

Swap two variables without a temp variable

a, b = 5, 10
a, b = b, a  # a is now 10, b is now 5

Calculate percentage change

old_value = 80
new_value = 100
change = (new_value - old_value) / old_value * 100
print(f"{change:.1f}%")  # 25.0%

Round to specific decimal places

value = 3.14159
rounded = round(value, 2)  # 3.14

Check if value is within a range

x = 5
if 0 < x < 10:
    print("within range")  # this runs

Yes, Python lets you chain comparisons like that. It reads as 0 < x and x < 10 but cleaner.

Integer division to get weeks from days

total_days = 25
weeks = total_days // 7
remaining_days = total_days % 7
print(f"{weeks} weeks and {remaining_days} days")  # 3 weeks and 4 days

Common Mistakes to Avoid

Quick Reference Table

CategorySymbols
Arithmetic+, -, *, /, //, %, **
Comparison==, !=, >, <, >=, <=
Logicaland, or, not
Bitwise&, |, ^, ~, <<, >>
Assignment=, +=, -=, *=, /=, //=, %=, **=, &=, |=, ^=
Identityis, is not
Membershipin, not in

Bookmark this page. You'll come back for the precedence table and the floor division gotcha.