Re: Python Exponent Question

2007-12-17 Thread Michael J. Fromberger
In article <[EMAIL PROTECTED]>, databyss <[EMAIL PROTECTED]> wrote: > I have a simple program and the output isn't what I expect. Could > somebody please explain why? > > Here's the code: > > #simple program > print "v = 2" > v = 2 > print "v**v = 2**2 =", v**v > print "v**v**v = 2**2**2 =",

Re: Python Exponent Question

2007-12-10 Thread Robert Kern
databyss wrote: > I have a simple program and the output isn't what I expect. Could > somebody please explain why? > > Here's the code: > > #simple program > print "v = 2" > v = 2 > print "v**v = 2**2 =", v**v > print "v**v**v = 2**2**2 =", v**v**v > print "v**v**v**v = 2**2**2**2 =", v**v**v**v

Re: Python Exponent Question

2007-12-10 Thread Christian Heimes
databyss wrote: > I would expect 2**2**2**2 to be 256 I stumbled upon it, too. 2**2**2**2 == 2**(2**(2**2)) == 2**16 == 65536 Christian -- http://mail.python.org/mailman/listinfo/python-list

Re: Python Exponent Question

2007-12-10 Thread Zero Piraeus
: > 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**

Re: Python Exponent Question

2007-12-10 Thread Tim Chase
databyss wrote: > I have a simple program and the output isn't what I expect. Could > somebody please explain why? > > Here's the code: > > #simple program > print "v = 2" > v = 2 > print "v**v = 2**2 =", v**v > print "v**v**v = 2**2**2 =", v**v**v > print "v**v**v**v = 2**2**2**2 =", v**v**v**v

Re: Python Exponent Question

2007-12-10 Thread Carsten Haese
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))

Python Exponent Question

2007-12-10 Thread databyss
I have a simple program and the output isn't what I expect. Could somebody please explain why? Here's the code: #simple program print "v = 2" v = 2 print "v**v = 2**2 =", v**v print "v**v**v = 2**2**2 =", v**v**v print "v**v**v**v = 2**2**2**2 =", v**v**v**v #end program Here's the output: >>>