🧙‍♂️ Python Wizard!

Arithmetic Operators

🔍 Deep Dive: Arithmetic Operators in Python

Arithmetic operators are used to perform mathematical operations between numeric values. Python supports several arithmetic operators that you’ll use regularly.


List of Arithmetic Operators

Operator Name Example Result
+ Addition 3 + 2 5
- Subtraction 5 - 2 3
* Multiplication 4 * 2 8
/ Division 8 / 4 2.0
// Floor Division 7 // 2 3
% Modulus 7 % 3 1
** Exponentiation 2 ** 3 8

Examples in Python


                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
            

Order of Operations (PEMDAS)

Python follows the PEMDAS order for evaluating expressions:


                result = 5 + 2 * 3    # result = 11
                result = (5 + 2) * 3  # result = 21
            

🧠 Quiz Yourself!

1. What does 10 % 4 return?



2. What will 2 ** 3 evaluate to?



3. Which operator performs modulus?