0

Beginner

Should I be begging learning languages like python on this app a lot of this stuff is confusing like what does the % do please add an example so I can learn easier and break it down for me if you will

28th Sep 2018, 11:55 PM
Raiden
Raiden - avatar
1 Answer
+ 2
% means modulus operator. it returns the remainder after division of two numbers. like 6%4 - 2 8%5 - 3 15%6 - 3 most of the time , we need an operator which can find out the remainder, and that's what % does that's all you should know. however, if you are interested to you what is the use of %. now since this basic operation, of remainder gives the crude magnitude, it has many practical application in programming. you can use it for various uses like suppose, I want to set range of variable from 0 to 9 only, so , (x%10) will always be between 0 and 9, the moment it reaches ten, it turns back to 0 , and begins incrementing again and so on. you can fetch the unit digits of a number, you can do conditional subtraction and much more.
29th Sep 2018, 1:01 AM
Sandeep Chatterjee