Python Modulo

What is the output of this code snippet?


x = 51 % 3

When I studied computer science, the professors pushed us to learn the theory behind modulo operations and residual classes. But many of us lacked motivation. We could not see why calculating the remainder of the division, i.e., modulo, is such an important concept.

Yet, many practical code projects later, I have gained the experience that modulo plays a role in most of them. Modulo is not optional. For example, suppose your code has a main loop and you want to execute a monitoring function each thousandth iteration i. Modulo is your friend here: simply check i%1000==0.

Learning these small code patterns is the key to become a great coder. You must know them by heart, without much thinking. This frees your mental energy and allows you to focus on the big picture. You will produce better and more meaningful code.
Burning code patterns into your head is the whole idea of Finxter.


Are you a master coder?
Test your skills now!


Related Video




Leave a Comment

Your email address will not be published. Required fields are marked *