Practice question
alister
alister.nospam.ware at ntlworld.com
Thu Oct 9 17:28:51 CEST 2014
On Mon, 06 Oct 2014 22:06:09 -0400, Seymore4Head wrote:
> 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.
no
you need to type in each snippet of code & see if they give the same
result when run.
--
In every non-trivial program there is at least one bug.
More information about the Python-list
mailing list