β Python Arithmetic Operators β Perform Basic Math in Python (2025)
π What Are Arithmetic Operators in Python?
Arithmetic operators in Python are used to perform basic mathematical operations such as addition, subtraction, multiplication, and division.
These operators work with numeric data types like int, float, and complex.
β List of Python Arithmetic Operators
| Operator | Description | Example | Result |
|---|---|---|---|
+ | Addition | 5 + 3 | 8 |
- | Subtraction | 5 - 3 | 2 |
* | Multiplication | 5 * 3 | 15 |
/ | Division (float) | 5 / 2 | 2.5 |
// | Floor Division | 5 // 2 | 2 |
% | Modulus (remainder) | 5 % 2 | 1 |
** | Exponentiation | 2 ** 3 | 8 |
β Examples
a = 10
b = 3
print(a + b) # 13
print(a - b) # 7
print(a * b) # 30
print(a / b) # 3.333...
print(a // b) # 3
print(a % b) # 1
print(a ** b) # 1000
π§ Key Notes
/always returns afloatresult, even if the numbers divide evenly.//gives the floor of the result (no decimal part).%is used to find remainders (often used in loops and conditions).**is used for powers (2 ** 3means 2 raised to the power 3).
π Summary β Arithmetic Operators in Python
| Task | Use This Symbol | Sample Code | Output |
|---|---|---|---|
| Add | + | 5 + 3 | 8 |
| Subtract | - | 5 - 3 | 2 |
| Multiply | * | 5 * 3 | 15 |
| Divide | / | 5 / 2 | 2.5 |
| Floor Divide | // | 5 // 2 | 2 |
| Modulus | % | 5 % 2 | 1 |
| Power | ** | 2 ** 3 | 8 |
β FAQs β Python Arithmetic Operators
β What are arithmetic operators in Python?
Arithmetic operators are symbols used to perform basic math operations like addition, subtraction, multiplication, division, modulus, floor division, and exponentiation.
β Whatβs the difference between / and // in Python?
/performs true division and returns afloat.//performs floor division and returns the largest whole number less than or equal to the result.
β What does the ** operator do in Python?
The ** operator is used for exponentiation (raising a number to a power).
Example: 2 ** 3 results in 8.
β What is the % operator used for?
% is the modulus operator. It returns the remainder after division.
Example: 10 % 3 returns 1.
β Can arithmetic operators work with floats and integers?
Yes. Python automatically promotes the result to float if any operand is a float.
Example: 5 + 3.0 returns 8.0.
Share Now :
