0

Incorrect?

the equation: 7%(5//2). how does this equal 0? 5//2 =2 so then 7%2 = 3.5 Am I doing my math wrong, or is this question incorrect?

30th Nov 2017, 8:58 PM
Qu35t10n3v3ryth1n9
Qu35t10n3v3ryth1n9 - avatar
5 Answers
+ 1
The % is mod division. It shows the remainder after division. So 7 % 5 would = 2. Because, 5 fits into 7 once, and the remainder is 2. ( // ) stands for (integer division) it tries to do division with whole numbers, so decimals aren't used. Even if you use 2.5, it essentially treats it as 2. So for you example: 5//2=2. Well, 2 fits into 5, 2 times. Therefore, the answer is 2. Regular division ( / ) would be 2.5, but integer division essentially ignores the decimal.
30th Nov 2017, 9:14 PM
Sapphire
0
According to this app, 0 was the correct answer needed in order to progress. This is what is confusing me.
2nd Dec 2017, 8:33 PM
Qu35t10n3v3ryth1n9
Qu35t10n3v3ryth1n9 - avatar
0
So after running it in python 3.6, it appears the answer is 1. I suppose the training question had the incorrect answer.
3rd Dec 2017, 12:57 AM
Qu35t10n3v3ryth1n9
Qu35t10n3v3ryth1n9 - avatar