What is the associativity of Python's ** operator?

前端 未结 4 1376
自闭症患者
自闭症患者 2020-12-11 04:21

I was just playing around with the python command line and the ** operator, which as far as I know performs a power function. So 2 ** 3 should be (and is) 8 because 2 * 2 *

4条回答
  •  再見小時候
    2020-12-11 05:14

    Also:

    2 ** (2 ** 2 ** 2)
    

    One way or the other, it becomes 2 ** 16.

    This is following standard mathematical operations, where: 234 becomes 2 81, instead of 84 and thus is 2417851639229258349412352, instead of 4096.

提交回复
热议问题