Python Exponent Question

Carsten Haese carsten at uniqsys.com
Mon Dec 10 13:24:00 EST 2007


On Mon, 2007-12-10 at 10:15 -0800, databyss wrote:
> I have a simple program and the output isn't what I expect.  Could
> somebody please explain why?
> [...]
> v**v**v**v = 2**2**2**2 = 65536
>
> I would expect 2**2**2**2 to be 256

Exponentiation is right-associative. 2**2**2**2 = 2**(2**(2**2)) =
2**(2**4) = 2**16 = 65536.

-- 
Carsten Haese
http://informixdb.sourceforge.net





More information about the Python-list mailing list