+ 2

Question About remainder

Could anyone explain me how to calculate this ? 7%(5//2) I understand the part that 5//2 = 2 Then 7%2 should be 0 though But the answer was 1 , I’m so confused now

11th Jul 2018, 8:52 AM
Midori
Midori - avatar
4 Respostas
+ 5
% sign represents the modulus function.It calculates the remainder. So when 7 is devided by 2, a remainder of 1 comes as 7 is an odd no. Thus 7%2=1and not 0. Hope this helps you,Midori.
12th Jul 2018, 5:40 AM
Aanisha Bhattacharyya
Aanisha Bhattacharyya - avatar
+ 5
https://en.m.wikipedia.org/wiki/Modulo_operation Modulo is integer division. An example: 2018%5 = 5*403 + 3
12th Jul 2018, 5:57 PM
Haris
Haris - avatar
+ 3
a%b is something like a - a//b * b so 7 % 2 = 7 - 7//2 * 2 7 - 3 * 2 7 - 6 = 1 or you can subtract b from a while a > b
11th Jul 2018, 9:03 AM
Mert Yazıcı
Mert Yazıcı - avatar
+ 2
thanks for explaining , but i just started it , i think i still got a lot to catch up , ill look into it more :) thanks!
11th Jul 2018, 9:17 AM
Midori
Midori - avatar