Practice question
Seymore4Head
Seymore4Head at Hotmail.invalid
Tue Oct 7 04:06:09 CEST 2014
On Tue, 7 Oct 2014 01:46:37 +0000 (UTC), Denis McMahon
<denismfmcmahon at gmail.com> wrote:
>On Sun, 05 Oct 2014 19:02:31 -0400, 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.
>
>I think part of the problem here is that you don't understand the
>expression.
>
>The expression:
>
>15 <= x < 30
>
>contains two conditions:
>
>15 <= x
>
>x < 30
>
>For the whole expression to be true, both conditions must be true, hence
>the equivalence is:
>
>(15 <= x) and (x < 30)
>
>to test this in python command line, see if the two different expressions
>give the same result for a suitable range of values of x:
>
>for x in range(50):
> if not (15 <= x < 30) == ((15 <= x) and (x < 30)):
> print "discrepancy"
>
>or
>
>for x in range(50):
> if (15 <= x < 30) == ((15 <= x) and (x < 30)):
> print "ok"
All of the practice questions up to this question had 4 answers. With
each question you could verify the correct answers by just copy and
pasting each choice into Python.
So when the instructions said I could verify this with Python I
assumed there might be some way to test if the question was == to each
answer.
More information about the Python-list
mailing list