+ 2
Какая разница между функциями // и %?
3 Answers
+ 4
// is a floor division - it rounds down the division result to the nearest lower integer
% returns the remainder of the division
17 // 4 = 4 (17/4=4.25, rounded down is 4)
17 % 4 = 1 (1 is a remainder of the division above)
+ 2
If you want to do both, divmod(a,b) returns (a//b, a%b)