I didn't got the remainder thing | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

I didn't got the remainder thing

7% (5//2)

22nd Jul 2016, 6:24 AM
Muhammad Ali
Muhammad Ali - avatar
2 Answers
+ 2
By following the PEMDAS rule alternative to BODMAS in maths, Parenthesis comes first. Double // produces exact integer not float and not to the nearest whole number( as in rounding a number) eg. 5//2 = 2 not 2.5 or 3 Also the remainder of modulo % division is it's answer, hence 7 % (5 // 2) = 7 % 2 ( parenthesis 1st and applying double // rule above ) Also, 7 divided by 2 = 3 remainder 1 and by applying modulo rule the remainder is the answer, hence 7 % 2 = 1 Therefore: 7 % (5 // 2) = 7 % 2 = 1
22nd Jul 2016, 6:58 AM
Benneth Yankey
Benneth Yankey - avatar
0
that was very clear thanks
22nd Jul 2016, 10:46 AM
Muhammad Ali
Muhammad Ali - avatar