What is the result of % in Python?

前端 未结 19 1721
粉色の甜心
粉色の甜心 2020-11-22 00:57

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

19条回答
  •  遇见更好的自我
    2020-11-22 01:06

    Modulus - Divides left hand operand by right hand operand and returns remainder.

    If it helps:

    1:0> 2%6
    => 2
    2:0> 8%6
    => 2
    3:0> 2%6 == 8%6
    => true
    

    ... and so on.

提交回复
热议问题