Path: csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!newsfeed.xs4all.nl!newsfeed1a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'subject:query': 0.07; '0.1': 0.09; 'curve': 0.09; 'linear': 0.09; 'properly.': 0.09; 'cc:addr:python-list': 0.11; '(before': 0.16; 'although,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'gentle': 0.16; 'hmm.': 0.16; 'lower,': 0.16; 'minus': 0.16; 'rough': 0.16; 'slight': 0.16; 'tolerance.': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'trying': 0.19; 'slightly': 0.19; '(the': 0.22; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'error': 0.23; "aren't": 0.24; 'subject:Code': 0.24; 'visible': 0.24; 'initial': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'train': 0.26; 'post': 0.26; 'subject:/': 0.26; 'header:In-Reply-To:1': 0.27; 'am,': 0.29; 'points': 0.29; "doesn't": 0.30; 'compared': 0.30; 'said,': 0.30; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '(my': 0.31; 'calculated': 0.31; 'decimal': 0.31; 'noted': 0.31; 'probably': 0.32; 'covered': 0.32; 'could': 0.34; 'problem.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'should': 0.36; 'seconds': 0.37; 'two': 0.37; 'pm,': 0.38; 'that,': 0.38; 'realize': 0.39; 'sure': 0.39; 'either': 0.39; 'how': 0.40; 'skip:u 10': 0.60; 'ian': 0.60; 'reach': 0.63; 'distance': 0.65; 'within': 0.65; 'here': 0.66; 'between': 0.67; 'brain': 0.68; 'stated': 0.69; 'therefore': 0.72; 'truth': 0.81; 'cuts': 0.84; 'difference.': 0.84; 'effectively,': 0.84; 'so...': 0.84; 'to:none': 0.92; 'average': 0.93 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:cc :content-type:content-transfer-encoding; bh=0GeRuZigI3m/iZUSYZUL62N3lnADLFEm2TE4DbPUoiY=; b=hngqfW7OHoeWf0oMcTGow3tuQjXvoh6Izyc/wEDpX5avdZDdo/eMxo3pf8+JvyebIS zWGwN3iNdwdfb3l7+3JV4PYEVAUpRPgDebMUIsA5rp060SSGHscoD8UWm+iFAxnhCKFp yXnAiG2ijudvToK/EGLCXL1gU96NIlnR2Dgbnusuqz+i58ZNw58crKyRUTFrPYZriTqy GKybjUSL2OlTCtHemac3F6KS2QBQFQFqLfhdMDRRcIooG049K7xIKStxiOfaW05hApMf I6UdN0EfC7pCtzDMtOvJru4vQlP2Ysrl35wjGCkZZ9f/FqDUpQKtWxITcX+4kw7Tq0VR jIxw== MIME-Version: 1.0 X-Received: by 10.68.248.7 with SMTP id yi7mr30145595pbc.31.1396342619308; Tue, 01 Apr 2014 01:56:59 -0700 (PDT) In-Reply-To: References: <533a3fd8$0$2909$c3e8da3$76491128@news.astraweb.com> <533a6af1$0$2909$c3e8da3$76491128@news.astraweb.com> Date: Tue, 1 Apr 2014 19:56:59 +1100 Subject: Re: Code style query: multiple assignments in if/elif tree From: Chris Angelico Cc: Python Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1396342622 news.xs4all.nl 2942 [2001:888:2000:d::a6]:50702 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:69496 On Tue, Apr 1, 2014 at 7:29 PM, Ian Kelly wrote: > On Tue, Apr 1, 2014 at 1:59 AM, Ian Kelly wrote: >> Given that, I have to question your figures: >> >>> 177.211111333333 >> >>> compared to 177.26527800000002 calculated the rough way. That's not bad= , >>> only about 5cm off! Effectively, your rough calculation was accurate to >>> one decimal place. >> >> As I noted the rough way should be an underestimate, so I'm not sure >> why it's an overestimate here. That said, I don't see where either of >> us made a mistake. > > And I realize now that this is also because the linear deceleration > assumption doesn't match the average deceleration stated in the > problem. It actually decelerates faster and cuts under the t=3D1s and > t=3D2s points in the velocity graph, and therefore is actually a > slightly larger underestimate. Okay... so... hmm. I'm trying to wrap a fried brain around your post here, and I'm not sure it covered it properly. It's like a tortilla with the meat spilling out. (My analogies aren't much saner when I'm not brain fried, trust me.) The important part here is to work out exactly how fast we'll be going at the end of two seconds of gentle braking (before the 0.85m/s/s bit begins). If that velocity is exactly the initial speed minus 0.625 m/s/s, then the error won't accumulate, and it's just a slight difference that's well within tolerance. But if that velocity is higher or lower, then it's going to be significant; the initial speed could be 111.1=CC=85 m/s (line speed of 400 km/h), and at that speed, 0.1 m/s difference could make a visible difference to the distance travelled (the difference between 111.0 and 111.1 m/s makes a 10m difference in the distance to reach 90 km/h or 25 m/s). Although, truth be told, that's probably still not *very* significant; it's 0.12 seconds of time difference. The exact deceleration curve isn't significant; all that matters is how far the train goes during that curve, and how much speed it loses. ChrisA