This operator can be useful for writing applications based on real-world scenarios. For example, say you have $20.00. You want to pass out exactly $3.50 to as many friends as possible, and you want to know how much money you will have leftover. So you would want to solve the questions “What is the quotient of 20.00/3.50?” and “What is the remainder of 20.00/3.50?” The answer to this word question would be “You can give 5 friends $3.50 and you will be left with $2.50.”
What is really great is that Google provides a mod function on its online calculator! So if you and your coder are ever debugging, you can check your mod equation on Google fairly easily. Just go to google.com and type “number1 % number2” and the calculator appears with your answer. There is even a button for mod on the calculator; it’s the % symbol.
Using pseudocode
Mod in pseudocode is often represented with the % symbol, because that is most commonly used in text-based languages like Python and Java.number1 % number2
Examples are
30 % 7
6.89 % 5.9
Using Scratch
In Scratch, you can find amod
block under the Operators category. For example, this image shows the mod block evaluating 9 mod 8
, which equals 1
.