A small quiz question

Ben Bacarisse ben.usenet at bsb.me.uk
Wed Aug 16 17:37:05 EDT 2017


Steve D'Aprano <steve+python at pearwood.info> writes:

> On Wed, 16 Aug 2017 11:38 pm, Ben Bacarisse wrote:
>
>> ram at 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)**f(1)**f(2)
>> 
>> Does Python actually specify what the output will be?  It's going to end
>> with 4 (the result from the REPL) and 4, 1 and 2 will appear on the
>> lines before, but is the order they appear specified?
>
> https://docs.python.org/3/reference/expressions.html#evaluation-order

Thanks.

-- 
Ben.



More information about the Python-list mailing list