Python % Percent -
i wondering if can me understand following python calculation answer calculates 97
:
100 - 25 * 3 % 4
i understand %
sign in python represents remaining of amount, however, i'm still not seeing how answer comes out 97
. if break calculation down understand grateful.. thanks!
it's evaluated in order python:
explanation of sum
*
, %
take precedence on -
, first evaluate 25 * 3 % 4
. *
, %
have same priority , associativity left right, evaluate left right, starting 25 * 3
. yields 75
. evaluate 75 % 4
, yielding 3
. finally, 100 - 3
97
.
Comments
Post a Comment