Arithmetic Operators
- Addition – ‘+’ – To Sum two or more numbers
>>> x = 56
>>> y = 45
>>> x + y
101
- Subtraction – ‘-’ – To Subtract two or more numbers
>>> a = 345
>>> b = 123
>>> a – b
222
- Multiplication – ‘*’ – To find the product of two or more numbers
>>> u = 45
>>> v = 3
>>> u * v
135
>>> a * b * u
1909575
- Division – ‘/’ – To divide two or more numbers. Answer is always a float.
>>> people = 6
>>> quantity = 42
>>> quantity / people
7.0
- Exponentiation – ‘**’ – To find y raised to power of x or vice versa.
>>> x = 5
>>> y = 2
>>> y ** x
32
>>> x ** y
25
- Modulus – ‘%’ – To find the remainder in any division.
>>> x = 22
>>> y = 7
>>> x / y
3.142857142857143
>>> x % y # Finding the remainder
1
>>> 343 % 4
3
- To Find Quotient in Division – ‘//’
>>> 343 / 4 # Division
85.75
>>> 343 % 4 # Remainder
3
>>> 343 // 4 # Quotient
85