# Python Arithmetic Operators

**Python Arithmetic Operators: Explained with Examples
**

**Arithmetic operations are fundamental in programming, and Python provides a rich set of arithmetic operators to perform various mathematical calculations. In this blog post, we will explore Python’s arithmetic operators in detail, including addition, subtraction, multiplication, division, exponentiation, remainder, floor division, and operator precedence.
**

**In Python there are Seven basic Arithmetic Operators;
**

Operators |
Description |

+ |
Addition |

– |
Subtraction |

* |
Multiplication |

/ |
Division |

** |
Exponentiation |

% |
Remainder |

// |
Floor Division |

**Addition (+)
**

**The addition operator (+) is used to add two numbers together. It can be used with both integers and floating-point numbers.
**

x = 5y = 3result = x + yprint(result) Â # Output: 8

**Subtraction (-)
**

**The subtraction operator (-)
is used to subtract one number from another. Like addition, it can be used with integers and floating-point numbers.
**

a = 10b = 4result = a - bprint(result) Â # Output: 6

**Multiplication (*)
**

**The multiplication operator (*)
is used to multiply two numbers. It works with both integers and floating-point numbers.
**

p = 7q = 3result = p * qprint(result) Â # Output: 21

**Division (/)
**

**The division operator (/)
is used to divide one number by another. It always returns a floating-point result.
**

m = 10n = 2result = m / nprint(result) Â # Output: 5.0

**Exponentiation (**)
**

**The exponentiation operator (**) is used to raise a number to a certain power.
**

base = 2exponent = 3result = base ** exponentprint(result) Â # Output: 8

**Remainder (%)
**

**The remainder operator (%), also known as the modulus operator. It calculates the remainder when one number is divided by another. It’s often used to check if a number is even or odd.
**

num = 11remainder = num % 2print(remainder) Â # Output: 1 (since 11 is odd)

**Floor Division (//)
**

**The floor division operator (//)
divides one number by another and rounds down to the nearest integer. It’s useful for obtaining the integer quotient of a division operation.
**

dividend = 10divisor = 3result = dividend // divisorprint(result) Â # Output: 3

**Operator Precedence
**

**Python follows the standard operator precedence rules. This means that some operators are evaluated before others. Here’s a brief overview:
**

**Exponentiation () has the highest precedence.**

**Multiplication (*), Division (/), and Floor Division (//) have the same precedence and are evaluated from left to right.**

**Addition (+) and Subtraction (-) also have the same precedence and are evaluated from left to right.**

**You can use parentheses to change the order of evaluation when needed.
**

result = (2 + 3) * 4print(result) Â # Output: 20

**In this example, the addition inside the parentheses is evaluated first, and then the multiplication is performed.
**

**Python provides a robust set of arithmetic operators for performing mathematical calculations in your programs. Understanding how these operators work and their precedence is essential for writing effective code. Whether you’re working with integers or floating-point numbers, Python’s arithmetic operators have you covered for all your mathematical needs. I hope you have learned this tutorial welled, but if you have any doubt you can ask in the comment section.
**

**Learn More;
**

## 0 Comments