➕ Operators & Expressions
Module 3 · Topic 1

Arithmetic Operators

Perform mathematical calculations using Python's 7 arithmetic operators, including floor division and exponentiation.

Theory

Arithmetic Operators in Python:

| Operator | Name | Example | Result |
|----------|------|---------|--------|
| + | Addition | 5 + 3 | 8 |
| - | Subtraction | 5 - 3 | 2 |
| * | Multiplication | 5 * 3 | 15 |
| / | Division (float) | 7 / 2 | 3.5 |
| // | Floor Division | 7 // 2 | 3 |
| % | Modulus (remainder) | 7 % 2 | 1 |
| ** | Exponentiation | 2 ** 3 | 8 |

Key Details:

  • / always returns float: 6 / 3 = 2.0 (not 2)
  • // floors toward negative infinity: -7 // 2 = -4 (not -3)
  • % follows the sign of the divisor: -7 % 2 = 1 (Python) vs -1 (C/Java)
  • ** has right-to-left associativity: 2**3**2 = 2**(3**2) = 512
  • Python integers have no overflow — 2**1000 works fine
Syntax
a + b    # Addition
a - b    # Subtraction
a * b    # Multiplication
a / b    # Float division
a // b   # Floor division
a % b    # Modulus
a ** b   # Exponentiation