Why 0 ** 0 equals 1 in python

后端 未结 3 460
独厮守ぢ
独厮守ぢ 2020-12-03 13:07

Why does 0 ** 0 equal 1 in Python? Shouldn\'t it throw an exception, like 0 / 0 does?

3条回答
  •  无人及你
    2020-12-03 13:51

    2^2 = (1+1)*(1+1) = 4 (two objects occured two times)

    2^1 = (1+1)*1 = 2 (two objects occured one time)

    2^0 = (1+1)*0 = 0 (two objects did not occur)

    1^2 = 1 *(1+1) = 2 (one object occured two times)

    1^1 = 1 *1 = 1 (one object occured one time)

    1^0 = 1 *0 = 0 (one object did not occur)

    0^2 = 0 *(1+1) = 0 (zero objects occured twice)

    0^1 = 0 *1 = 0 (zero objects occured once)

    0^0 = 0 *0 = 0 (zero objects did not occur)

    Therefore you cannot make something from nothing!

提交回复
热议问题