+ 1
Python
how >>>7%(5//2)=1? Can anyone explain it to me?
2 Answers
+ 7
Solve what's in the parenthesis first because of order of precedence:
5 // 2 == 2
The // operator is for floor division. It truncates the result after division (throws away all the decimal places).
Then 7 % 2 == 1.
The % operator gets the remainder after division. It is called modulus or simply mod operator.
P.S.: Use double equal sign "==" when dealing with equations. A single equal sign is the assignment operator, whereas double is for comparison.
+ 1
5//2 == 2 (2.5 without remainder)
7%2 == 1 (Remainder after 7//2)



