I have the same question as the previous person to which no one answered.

What does “floor of the result of the division” mean?

Please explain why 17//10 results in 1, and why 17%10 results in 3
I have the same question as the previous person to which no one answered.
What does “floor of the result of the division” mean?
Please explain why 17//10 results in 1, and why 17%10 results in 3
By “floor of the result of the division”, we are referring to a two step process that involves evaluating the division operation to yield a number and then taking the floor of that number.
7 // 3
is 2 and 7 % 3
is 1. That result can be rewritten as 2 1/3, which is equivalent to the fraction 7 over 3.Next, you asked why 17 // 10
results in 1
. However, the result of evaluating that expression is 2
.
Let’s look at floating point division first: 17 / 10
evaluates to 1.7
.
Now, let’s look at the integer division: 17 // 10
evaluates to 2
. (Following the rule for floor, 2 is the largest integer that is less than or equal to 1.7.)
And the modulo: 17 % 10
evaluates to 3. This is the remainder of the integer division.
As we did before, this can be written as 2 3/10, which is equivalent to the fraction 17 / 10.