Practice question

Seymore4Head Seymore4Head at Hotmail.invalid
Sun Oct 5 20:18:13 EDT 2014


On Sun, 05 Oct 2014 19:47:40 -0400, Terry Reedy <tjreedy at udel.edu>
wrote:

>On 10/5/2014 7:02 PM, Seymore4Head wrote:
>> For the record, I don't want a hint.  I want the answer.
>> I see a practice question is similar to this.
>> 15 <= x < 30  And it wants a similar expression that is equivalent.
>> So the right answer is 15<= x or x <30
>> but one of the other answers is
>> not (15<= x and x <30)
>>
>> But it says.....remember you can try this out in the Python shell.
>> How?
>
>For instance,
>for x in (10, 20, 30, 40):
>     print((15 <= x < 30) == (15<= x and x <30))

I think I get it now.  You are using a sample of answers.  So you
could actually just run through them all.  (I haven't tried this yet)

for x in range(lo,hi)
     print((15 <= x < 30) == (15<= x and x <30))

Thanks



More information about the Python-list mailing list