CKTIS / Python
Operator %
Computes the remainder paired with floor division.
Version: Python 3.14; repository image, production runtime not attested
Syntax
left % rightComputes the remainder paired with floor division.
Use the integer remainder to wrap a position into the range of a positive period. With a positive divisor, the result is always at least zero and strictly smaller than that divisor.
The floor quotient times the divisor plus this remainder equals the original integer. A zero divisor fails. On strings the same symbol selects a distinct formatting protocol.
For integers a nonzero remainder has the sign of the divisor.
Syntax
left % right
__mod__, __rmod__ · ZeroDivisionError
Worked example
-7 % 3 → 2
7 % -3 → -2
a == (a // b) * b + a % b (int; b != 0)
"%02d" % 5 → "05"
Examples
print(19 % 4)
print(19 % -4)
Result
3 -1
For integers a nonzero remainder has the sign of the divisor.