Fix Python – How to calculate a mod b in Python?

Question

Asked By – Hick

Is there a modulo function in the Python math library?

Isn’t 15 % 4, 3? But 15 mod 4 is 1, right?

Now we will see solution for issue: How to calculate a mod b in Python?


Answer

There’s the % sign. It’s not just for the remainder, it is the modulo operation.

This question is answered By – eduffy

This answer is collected from stackoverflow and reviewed by FixPython community admins, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0