+ 3
I dont understand how does the two slashes work
5 odpowiedzi
+ 9
I'm guessing you're talking about floor division, also called integer division.
if a / b is an integer, then a // b is that integer.
if a / b is not an integer, then a // b is the next integer lower than a / b.
e.g.
20 / 5 = 4, so 20 // 5 = 4
20 / 6 = 3.33333, so 20 // 6 = 3 because 3 is the next integer lower than 3.33333
It's a bit strange with negative numbers:
-20 / 6 = -3.33333 and -20 // 6 = -4 because -4 is the next integer lower than -3.33333
Floor division and the modulo operator (%) kind of work together, if you think of the modulo as the remainder of a division:
20 // 6 = 3 and 20 % 6 = 2 because 2 = 20 - 3 * 6
so you get the relationship
a = b * (a // b) + a % b
oops got a bit carried away .... you weren't asking about double backslashes, were you? 🙃
+ 3
thanks @David Ashton an impressive answer
+ 2
I am asking it in python language what does // do and %do while calculating ..
+ 1
What language? Backslashes or forward slashes?