One of the most common ways to introduce someone to programming is by starting with printing Hello World and then showing them how to do math operations using simple coding instructions.
This can make it easier for newcomers to learn since they already know basic arithmetic operations and now can see how they can do them with programming instructions.
If you also come from other programming languages, you probably know that the division operator between 2 integer numbers results in another integer.
Let’s see that in the following example:
If any of the numbers is not an integer, then it is going to result in a true division (just like the one you learned at school):
Here comes another way to do the division that you may have not had the chance to stumble upon in other programming languages.
If you use for the division a double slash, you are going to get the nearest whole number from the true division:
This works whether you use integers or nonintegers as the operands:
That’s it for this article.
I hope you find it useful.