What does the %
in a calculation? I can\'t seem to work out what it does.
Does it work out a percent of the calculation for example: 4 % 2
Somewhat off topic, the %
is also used in string formatting operations like %=
to substitute values into a string:
>>> x = 'abc_%(key)s_'
>>> x %= {'key':'value'}
>>> x
'abc_value_'
Again, off topic, but it seems to be a little documented feature which took me awhile to track down, and I thought it was related to Pythons modulo calculation for which this SO page ranks highly.