Re: A small quiz question

2017-08-16 Thread Marko Rauhamaa
Dennis Lee Bieber : > I suppose, the two in combination imply that the calls to "f()" > occur first in left to right, but then the "**" are applied to the > returned values right to left -- rather than having the calls > performed in the exponentiation order. Yes, and parentheses, operator

Re: A small quiz question

2017-08-16 Thread Steve D'Aprano
On Thu, 17 Aug 2017 09:12 am, Dennis Lee Bieber wrote: > I suppose, the two in combination imply that the calls to "f()" occur > first in left to right, but then the "**" are applied to the returned > values right to left -- rather than having the calls performed in the > exponentiation order. St

Re: A small quiz question

2017-08-16 Thread Ben Bacarisse
Steve D'Aprano writes: > On Wed, 16 Aug 2017 11:38 pm, Ben Bacarisse wrote: > >> r...@zedat.fu-berlin.de (Stefan Ram) writes: >> >>> I wrote my first Python quiz question! >>> >>> It goes like this: >>> >>> Can you predict (without trying it out) what the Python >>> console will output a

Re: A small quiz question

2017-08-16 Thread Marko Rauhamaa
Ian Kelly : > On Wed, Aug 16, 2017 at 6:51 AM, Dennis Lee Bieber > wrote: >>>def f(i): print(i); return i; >>> >>>f(4)**f(1)**f(2) >>> >> >> As a first guess >> >> 2 >> 1 >> 4 >> >> 4 >> >> since in many languages, exponentiation associates right to left > > I thought the same thing but f

Re: A small quiz question

2017-08-16 Thread Ian Kelly
On Wed, Aug 16, 2017 at 6:51 AM, Dennis Lee Bieber wrote: > On 16 Aug 2017 11:06:26 GMT, r...@zedat.fu-berlin.de (Stefan Ram) declaimed > the following: > >> I wrote my first Python quiz question! >> >> It goes like this: >> >> Can you predict (without trying it out) what the Python >> console

Re: A small quiz question

2017-08-16 Thread breamoreboy
On Wednesday, August 16, 2017 at 2:52:09 PM UTC+1, Steve D'Aprano wrote: > On Wed, 16 Aug 2017 10:29 pm, breamoreboy wrote: > > > How do you expect to get four lines of output from the three function calls? > > In the REPL (the interactive interpreter) the result of evaluating the line is > print

Re: A small quiz question

2017-08-16 Thread breamoreboy
On Wednesday, August 16, 2017 at 12:45:13 PM UTC+1, Steve D'Aprano wrote: > On Wed, 16 Aug 2017 09:06 pm, Stefan Ram wrote: > > > I wrote my first Python quiz question! > > > > It goes like this: > > > > Can you predict (without trying it out) what the Python > > console will output afte

Re: A small quiz question

2017-08-16 Thread Steve D'Aprano
On Wed, 16 Aug 2017 11:38 pm, Ben Bacarisse wrote: > r...@zedat.fu-berlin.de (Stefan Ram) writes: > >> I wrote my first Python quiz question! >> >> It goes like this: >> >> Can you predict (without trying it out) what the Python >> console will output after the following three lines have

Re: A small quiz question

2017-08-16 Thread Steve D'Aprano
On Wed, 16 Aug 2017 10:29 pm, breamore...@gmail.com wrote: > How do you expect to get four lines of output from the three function calls? In the REPL (the interactive interpreter) the result of evaluating the line is printed. -- Steve “Cheer up,” they said, “things could be worse.” So I cheere

Re: A small quiz question

2017-08-16 Thread Ben Bacarisse
r...@zedat.fu-berlin.de (Stefan Ram) writes: > I wrote my first Python quiz question! > > It goes like this: > > Can you predict (without trying it out) what the Python > console will output after the following three lines have > been entered? > > def f(i): print(i); return i; > > f(4)**

Re: A small quiz question

2017-08-16 Thread Steve D'Aprano
On Wed, 16 Aug 2017 09:06 pm, Stefan Ram wrote: > I wrote my first Python quiz question! > > It goes like this: > > Can you predict (without trying it out) what the Python > console will output after the following three lines have > been entered? > > def f(i): print(i); return i; > >

Re: A small quiz question

2017-08-16 Thread Joel Goldstick
On Wed, Aug 16, 2017 at 7:06 AM, Stefan Ram wrote: > I wrote my first Python quiz question! > > It goes like this: > > Can you predict (without trying it out) what the Python > console will output after the following three lines have > been entered? > > def f(i): print(i); return i; > >