We use multiple arithmetic operation in python. such as +,-,*,/,%
we use + is for addition of two numbers.
for example: 2+3 will perform addition and it will return 5 as a result.
3–2 will perform subtraction and it will return 1 as a result.
3*3 will perform multiplication and it will return 9 as a result.
6/2 will perform division and it will return 3 as a result.
now, when we see operator % in calculator we think that it will calculate percentage.
but here in programming language the % operator is called modulo operator.
This % operator will return reminder of division.
x % y
13%5 will return 3
To demonstrate this, let me take example of apples.
suppose, we have 13 apples and we want to make a group of 5.
from the above picture, we have divided our 13 apples in the group of 5 (because we have 13%5). here leftover Apples are 3.
so, we will get 3 as a answer.
we can find odd and even numbers with the help of %.
3%2 will return 1
2%2 will return 0
for example we have list of apples:
for apple in range(0,10):
if (apple%2) != 0: