- Arithmetic operators: Arithmetic operators are used to perform mathematical operations like addition, subtraction, multiplication and division.
|+||Addition: adds two operands||x + y|
|–||Subtraction: subtracts two operands||x – y|
|*||Multiplication: multiplies two operands||x * y|
|/||Division (float): divides the first operand by the second||x / y|
|//||Division (floor): divides the first operand by the second||x // y|
|%||Modulus: returns the remainder when first operand is divided by the second||x % y|
|**||Power : Returns first raised to power second||x ** y|
for example, open any of your text editor(notepad/notepad++), then copy the code below
a = 9 b = 4 #Addition of numbers add = a + b #Subtraction of numbers sub = a - b #Multiplication of number mul = a * b #Division(float) of number div1 = a / b #Division(floor) of number div2 = a // b #Modulo of both number mod = a % b #Power p = a ** b print results print(add) print(sub) print(mul) print(div1) print(div2) print(mod) print(p)
Save this file with test.py, then search your Command Prompt (.cmd) in your windows, open it, then type: python test.py, or python3 test.py.
13 5 36 2.25 2 1 6561