Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78798
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <illusiontechniques@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.007 |
| X-Spam-Evidence | '*H*': 0.99; '*S*': 0.00; '21,': 0.07; 'odd': 0.07; 'assumed': 0.09; 'integers': 0.09; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'posted': 0.15; '1:48': 0.16; 'cases:': 0.16; 'instead:': 0.16; 'to:addr:pearwood.info': 0.16; "to:name:steven d'aprano": 0.16; 'unequal,': 0.16; 'yet)': 0.16; 'exception': 0.16; 'all.': 0.16; 'wrote:': 0.18; 'cc:addr:python.org': 0.22; 'print': 0.22; "haven't": 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; '15,': 0.26; 'equivalent': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'am,': 0.29; 'raise': 0.29; 'message-id:@mail.gmail.com': 0.30; 'url:mailman': 0.30; 'assert': 0.31; "d'aprano": 0.31; 'idea,': 0.31; 'steven': 0.31; 'probably': 0.32; 'run': 0.32; 'url:python': 0.33; 'cases': 0.33; 'screen': 0.34; 'could': 0.34; 'except': 0.35; 'equal': 0.35; 'test': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'really': 0.36; 'false': 0.36; 'url:listinfo': 0.36; 'next': 0.36; 'url:org': 0.36; 'two': 0.37; 'rather': 0.38; 'url:mail': 0.40; 'lower': 0.61; 'numbers': 0.61; '(that': 0.65; '30,': 0.65; 'sample': 0.67; 'between': 0.67; 'line,': 0.68; 'dozens': 0.84; 'stop,': 0.84 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=ts0kT4NsuaFdP1Ux4mASUI9BnBoAsZIHJ2FW4+HnOdE=; b=m5aV35CbwfXl3o71u+9vkYbNIk2Dp/46Sp7rWY4IFTaK4DzqxnfAHcmcp8EzusHUaQ UOw/KPsqUNJBT/aXYnKTpN9Y1rQ08m3Qs0R5rL5ksUzBj0HqAoQsCmm9CaMFpHra40i7 Mb442ad2sbXAPFkUMgch4rPmBLt2voR1MOTX6+tQ6Ax/j+I4dEx0eJSpNiZrQQoNXuoe jvpc2wD2FxMvSOx9K9w/SxPkCN1Rdoe2HntGcwnNB4ugnVHEDtDi1JCkF8HHkPMjT0Kb 69BvvPBhprZ6pRzqNts104KrfLBldjPp+22gSTOjDIhy9gUmmlnKwGhPFfPniiqI4Pez wqpw== |
| MIME-Version | 1.0 |
| X-Received | by 10.152.42.142 with SMTP id o14mr3924956lal.86.1412685813618; Tue, 07 Oct 2014 05:43:33 -0700 (PDT) |
| In-Reply-To | <5433a8f7$0$2916$c3e8da3$76491128@news.astraweb.com> |
| References | <h2j33adothf9uctcdp5psqk2cclr01961r@4ax.com> <mailman.14621.1412552876.18130.python-list@python.org> <pnn33a1cqtpbagua005b0cfhb587sfla9t@4ax.com> <5433a8f7$0$2916$c3e8da3$76491128@news.astraweb.com> |
| Date | Tue, 7 Oct 2014 05:43:33 -0700 |
| Subject | Re: Practice question |
| From | C Smith <illusiontechniques@gmail.com> |
| To | "Steven D'Aprano" <steve@pearwood.info> |
| Content-Type | text/plain; charset=UTF-8 |
| Cc | python-list@python.org |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14658.1412685815.18130.python-list@python.org> (permalink) |
| Lines | 45 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1412685815 news.xs4all.nl 2916 [2001:888:2000:d::a6]:39621 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:78798 |
Show key headers only | View raw
Steven D'Aprano wrote: >>With two numbers, 15 and 30, all you really need is five test cases: My solution assumed integers also, but after I posted it, I thought: "What about floating points?" On Tue, Oct 7, 2014 at 1:48 AM, Steven D'Aprano <steve@pearwood.info> wrote: > On Sun, 05 Oct 2014 20:18:13 -0400, Seymore4Head wrote: > >> 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)) > > Yes, except using print is probably not the best idea, since you might > have dozens of True True True True ... printed, one per line, and if you > blink the odd False might have scrolled off screen before you notice. > > With two numbers, 15 and 30, all you really need is five test cases: > > - a number lower than the smaller of the two numbers (say, 7); > - a number equal to the smaller of the two numbers (that is, 15); > - a number between the two numbers (say, 21); > - a number equal to the larger of the two numbers (that is, 30); > - a number higher than the larger of the two numbers (say, 999); > > > The exact numbers don't matter, so long as you test all five cases. And > rather than printing True True True... let's use assert instead: > > > for x in (7, 15, 21, 30, 999): > assert (15 <= x < 30) == (15<= x and x <30) > > > If the two cases are equal, assert will do nothing. But if they are > unequal, assert will raise an exception and stop, and you know that the > two cases are not equivalent and can go on to the next possibility. > > > -- > Steven > -- > https://mail.python.org/mailman/listinfo/python-list
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Practice question Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-05 19:02 -0400
Re: Practice question Roy Smith <roy@panix.com> - 2014-10-05 19:06 -0400
Re: Practice question Ned Batchelder <ned@nedbatchelder.com> - 2014-10-05 19:14 -0400
Re: Practice question Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-05 20:07 -0400
Re: Practice question Ned Batchelder <ned@nedbatchelder.com> - 2014-10-05 21:25 -0400
Re: Practice question Steven D'Aprano <steve@pearwood.info> - 2014-10-07 08:41 +0000
Re: Practice question Skip Montanaro <skip.montanaro@gmail.com> - 2014-10-05 18:33 -0500
Re: Practice question Rustom Mody <rustompmody@gmail.com> - 2014-10-05 19:47 -0700
Re: Practice question Skip Montanaro <skip.montanaro@gmail.com> - 2014-10-06 08:04 -0500
Re: Practice question Rustom Mody <rustompmody@gmail.com> - 2014-10-06 09:23 -0700
Re: Practice question Chris Angelico <rosuav@gmail.com> - 2014-10-07 03:52 +1100
Re: Practice question Rustom Mody <rustompmody@gmail.com> - 2014-10-06 10:05 -0700
Re: Practice question Chris Angelico <rosuav@gmail.com> - 2014-10-07 04:13 +1100
Re: Practice question Steven D'Aprano <steve@pearwood.info> - 2014-10-06 20:49 +0000
Re: Practice question "Redge @ Versalytics.com" <versalytics@gmail.com> - 2014-10-06 20:54 -0400
Re: Practice question Rustom Mody <rustompmody@gmail.com> - 2014-10-08 09:14 -0700
Re: Practice question Chris Angelico <rosuav@gmail.com> - 2014-10-09 03:23 +1100
Re: Practice question Skip Montanaro <skip.montanaro@gmail.com> - 2014-10-08 11:27 -0500
Re: Practice question Rustom Mody <rustompmody@gmail.com> - 2014-10-08 09:41 -0700
Re: Practice question Terry Reedy <tjreedy@udel.edu> - 2014-10-05 19:47 -0400
Re: Practice question Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-05 20:18 -0400
Re: Practice question Steven D'Aprano <steve@pearwood.info> - 2014-10-07 08:48 +0000
Re: Practice question C Smith <illusiontechniques@gmail.com> - 2014-10-07 05:43 -0700
Re: Practice question C Smith <illusiontechniques@gmail.com> - 2014-10-05 16:24 -0700
Re: Practice question Denis McMahon <denismfmcmahon@gmail.com> - 2014-10-07 01:46 +0000
Re: Practice question Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-10-06 22:06 -0400
Re: Practice question alister <alister.nospam.ware@ntlworld.com> - 2014-10-09 15:28 +0000
csiph-web