In this chapter let us all look at the Python Arithmetic Operators and understand how to use them all. Python arithmetic operators basically operate in the same manner as the other programming lnaguage operators and below are some of them.
Addition Operator
x = 1 y = 2 z = x + y # 3
Subtraction Operator
x = 1 y = 2 z = x - y # -1
Multiplication Operator
x = 1 y = 3 z = x * y # 3
Division Operator
x = 6 y = 2 z = x / y # 3
Modulus Operator
x = 6 y = 2 z = x % y # 0
Exponentiation Operator
x = 6 y = 2 z = x ** y # 36
Floor division Operator
x = 6 y = 4 z = x # y # 1, as you can see the decimal point has been truncated
Bitwise And Operator
x = 3 y = 2 z = x & y # 2 where 0011 & 0010 = 0010
Bitwise Or Operator
x = 3 y = 2 z = x | y # 3 where 0011 | 0010 = 0011
Bitwise Exclusive Or Operator
x = 3 y = 2 z = x ^ y # 1 where 0011 ^ 0010 = 0001
There are still many other arithmetic operators I do not include in this chapter and you can find all of them on the Python main document page!