How is >>>7%(5//2) =1 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

How is >>>7%(5//2) =1

I don't have a good understanding how this does it's calculation.

9th Feb 2017, 7:09 PM
Robley Ochieng Otieno
Robley Ochieng Otieno - avatar
5 Answers
+ 13
5//2 does a division and excludes the remainder, so 5//2 = 2 So you have 7%2, which does the division but gives as a result the remainder, so 7/2 = 3 and we have a remainder of 1, so 7%(5//2) = 1 Hope this helped.
9th Feb 2017, 7:47 PM
aaa
+ 7
// is the integer division operator, that is, the quotient of the division of two numbers. % is the remainder of a division. Because of the (parentheses), you should compute // first.
9th Feb 2017, 7:11 PM
Álvaro
+ 5
(5//2) = 2 because of floor division 7%2 = 1 because if you divide 7 by 2 the remainder is 1 (modulo operation)
9th Feb 2017, 7:14 PM
Mario L.
Mario L. - avatar
+ 1
Thank you guys.
9th Feb 2017, 8:12 PM
Robley Ochieng Otieno
Robley Ochieng Otieno - avatar
0
Its simple but something that you really need understand... * first solve the brackets...which give you 5//2 = 2 not 2.5(because it divides integer And to get exact result to parse this value in Float) * then, 7%2=1(Remainder) and 3(Quotients)
2nd Mar 2017, 7:06 AM
Sanjeev Pratap Singh
Sanjeev Pratap Singh - avatar