How to calculate a mod b in Python?

后端 未结 7 1274
迷失自我
迷失自我 2020-12-12 21:47

Is there a modulo function in the Python math library?

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

7条回答
  •  南笙
    南笙 (楼主)
    2020-12-12 21:50

    >>> 15 % 4
    3
    >>>
    

    The modulo gives the remainder after integer division.

提交回复
热议问题