Python Exponent Question

Zero Piraeus schesis at gmail.com
Mon Dec 10 13:25:41 EST 2007


:

> v = 2
> v**v = 2**2 = 4
> v**v**v = 2**2**2 = 16
> v**v**v**v = 2**2**2**2 = 65536
>
> I would expect 2**2**2**2 to be 256

"... in an unparenthesized sequence of power and unary operators, the
operators are evaluated from right to left ..."
 - http://docs.python.org/ref/power.html

So, 2**2**2**2 = 2**(2**(2**2)) = 65536

 -[]z.



More information about the Python-list mailing list