0

Can someone please explain this

Can someone please explain to me how modulo (%) works? Thanks

10th Jun 2017, 5:58 PM
piano
piano - avatar
3 ответов
+ 5
Check out this thread. I give an answer there on this, including negative cases: https://www.sololearn.com/discuss/272747/?ref=app
10th Jun 2017, 6:11 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 1
It gives remainder after it is divided as many times as it can. 4%2...... 0 2, 4 - 0 left over 10%2.... 0 2,4,6,8,10 - 0 left over 10%3.... 1 3,6,9 - 1 left over 15%4.... 3 4,8,12 - 3 left over Common use is to check for even or odd numbers. if number%2 == 0: Number is even if number%2 != 0: Number is odd
10th Jun 2017, 7:04 PM
LordHill
LordHill - avatar
0
it returns the reminder value of division as: 3%2=1 - 3/2=1.5 so the float no. is 0.5 multiply it to 2 not 3 so it equal 1 so 3%2=1 - 10 %6=4 10/6=1.6666666666667 0.6666666666667 × 6=4 10%6=4
10th Jun 2017, 9:51 PM
Nour Ayman