Modulas Operator
Link will be apear in 15 seconds.
Well done! you have successfully gained access to Decrypted Link.
MODULAS OPERATOR:
The modulus operator works on
integers (and integer expressions) and yields the remainder when the first
operand is divided by the second.
Example:
In Python, the modulus
operator is a percent sign (%).
•
The syntax is the same as for other
operators:
>>> quotient = 7 / 3
>>> print quotient
2
>>> remainder = 7 % 3
>>> print remainder
1
Uses:
So 7 divided by 3 is 2 with 1
left over.
•
Check whether one number is divisible
by another if x % y is zero, then x is divisible by y.
•
you can extract the right-most digit
or digits from a number.
•
For example,
x % 10
yields the right-most digit of x (in base 10). Similarly x % 100 yields the last two digits.