+ 4
Can anyone help me?
I didn't really understand the quotient and remainder. please explain it to me.
3 Respostas
+ 27
If you divide 7 by 3, then the result is 2, because 3*2=6 and 6 is the nearest whole number. Thus the quotient is 2.
Now what remains? 7-6 = 1. So 1 is the remainder.
+ 7
Things get a bit tricky, though, when negatives come in:
14 % 5 = 4
14 % -5 = -1
-14 % 5 = 1
-14 % -5 = -4
It always counts the remainder comparing the dividend to the *lower* no-fraction number. So to 10 and -15 in the examples above, respectively.
In Python, unlike some other languages, the modulo result always has the same sign as the divisor (observe the sign of 5 in the examples above).
+ 4
thanks for explaining it