Modulo operator in Python

后端 未结 5 1954
無奈伤痛
無奈伤痛 2020-11-27 20:16

What does modulo in the following piece of code do?

from math import *
3.14 % 2 * pi

How do we calculate modulo on a floating point number?

5条回答
  •  庸人自扰
    2020-11-27 20:29

    same as a normal modulo 3.14 % 6.28 = 3.14, just like 3.14%4 =3.14 3.14%2 = 1.14 (the remainder...)

提交回复
热议问题