In Python, Arithmetic Operators are used with numeric values to perform common mathematical operations. These are the building blocks of any algorithm involving calculations, from simple addition to complex data processing.
Python supports several arithmetic operators, including standard ones found in basic calculators and specific ones like "Floor Division" and "Modulus" which are vital in programming logic.
| Operator | Name | Description |
| + | Addition | Adds values on either side of the operator. |
| - | Subtraction | Subtracts the right-hand operand from the left-hand operand. |
| * | Multiplication | Multiplies values on either side of the operator. |
| / | Division | Divides the left operand by the right operand. Always returns a float. |
| // | Floor Division | Divides and returns the largest possible integer (rounds down). |
| % | Modulus | Returns the remainder of the division. |
| ** | Exponentiation | Performs "power" calculations (e.g., $2^3$). |
In Python 3, the / operator performs floating-point division. Even if you divide two integers perfectly (like 4 / 2), the result is 2.0.
The // operator, however, performs integer division, discarding the decimal remainder.
This is extremely useful for logic tasks, such as:
Checking Parity: if x % 2 == 0: (checks if a number is even).
Cycling: Keeping a value within a specific range (like clock math).
Python follows standard mathematical order:
Parentheses ()
Exponentiation **
Multiplication and Division (*, /, //, %)
Addition and Subtraction (+, -)
# Initialize variables a = 15 b = 4 # Basic Operations print(f"Addition: {a} + {b} = {a + b}") # 19 print(f"Subtraction: {a} - {b} = {a - b}") # 11 print(f"Multiplication: {a} * {b} = {a * b}") # 60 # Division Varieties print(f"Float Division: {a} / {b} = {a / b}") # 3.75 print(f"Floor Division: {a} // {b} = {a // b}") # 3 (removes .75) # Remainder and Power print(f"Modulus (Remainder): {a} % {b} = {a % b}") # 3 print(f"Exponent (Power): {a} ** {b} = {a ** b}") # 50625 # Complex Expression (Order of Operations) result = (10 + 2) * 5 / 2 ** 2 # Calculation: 12 * 5 / 4 -> 60 / 4 -> 15.0 print(f"Complex Result: {result}")
While technically an "Arithmetic Operator," the + sign can also be used with strings to join them together, and the * sign can repeat strings.
print("Python" + "Is" + "Fun") # Concatenation print("Echo! " * 3) # Repetition
Copyright ©2025. All Rights Reserved Emblab THE RAVE INNOVATION