Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #69496

Re: Code style query: multiple assignments in if/elif tree

References (3 earlier) <CALwzidmEqc45K49c3agMzRzpAtEqejGF2svpPOZXg5X6dbBnGw@mail.gmail.com> <mailman.8774.1396335341.18130.python-list@python.org> <533a6af1$0$2909$c3e8da3$76491128@news.astraweb.com> <CALwzid=jt=oCPD1Z-D_DtxA9=fdc-ziE7uhv_rqk0ci6+3VM6g@mail.gmail.com> <CALwzidmzArh543XSL88_hnJarB8gLOGG9jNq=dpepte=z4fvLg@mail.gmail.com>
Date 2014-04-01 19:56 +1100
Subject Re: Code style query: multiple assignments in if/elif tree
From Chris Angelico <rosuav@gmail.com>
Newsgroups comp.lang.python
Message-ID <mailman.8789.1396342622.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Apr 1, 2014 at 7:29 PM, Ian Kelly <ian.g.kelly@gmail.com> wrote:
> On Tue, Apr 1, 2014 at 1:59 AM, Ian Kelly <ian.g.kelly@gmail.com> 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=1s and
> t=2s 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̅ 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

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 01:33 +1100
  Re: Code style query: multiple assignments in if/elif tree Marko Rauhamaa <marko@pacujo.net> - 2014-03-31 18:40 +0300
    Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 03:03 +1100
      Re: Code style query: multiple assignments in if/elif tree Rustom Mody <rustompmody@gmail.com> - 2014-03-31 09:20 -0700
        Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 03:29 +1100
          Re: Code style query: multiple assignments in if/elif tree "Rhodri James" <rhodri@wildebst.org.uk> - 2014-03-31 21:31 +0100
    Re: Code style query: multiple assignments in if/elif tree Ned Batchelder <ned@nedbatchelder.com> - 2014-03-31 17:42 -0400
    Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 09:50 +1100
    Re: Code style query: multiple assignments in if/elif tree Ben Finney <ben+python@benfinney.id.au> - 2014-04-01 09:57 +1100
    Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 10:12 +1100
      Re: Code style query: multiple assignments in if/elif tree Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-04-01 00:57 +0000
    Re: Code style query: multiple assignments in if/elif tree Ethan Furman <ethan@stoneleaf.us> - 2014-03-31 17:30 -0700
  Re: Code style query: multiple assignments in if/elif tree Steven D'Aprano <steve@pearwood.info> - 2014-04-01 04:26 +0000
    Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 16:01 +1100
      Re: Code style query: multiple assignments in if/elif tree Steven D'Aprano <steve@pearwood.info> - 2014-04-01 07:20 +0000
        Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 18:35 +1100
          Re: Code style query: multiple assignments in if/elif tree Steven D'Aprano <steve@pearwood.info> - 2014-04-01 08:07 +0000
            Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 19:12 +1100
        Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 02:18 -0600
        Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 02:24 -0600
    Re: Code style query: multiple assignments in if/elif tree Rustom Mody <rustompmody@gmail.com> - 2014-03-31 22:45 -0700
      Re: Code style query: multiple assignments in if/elif tree David Hutto <dwightdhutto@gmail.com> - 2014-04-01 02:05 -0400
      Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 00:28 -0600
    Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 00:13 -0600
    Re: Code style query: multiple assignments in if/elif tree David Hutto <dwightdhutto@gmail.com> - 2014-04-01 02:24 -0400
    Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 00:39 -0600
    Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 17:55 +1100
      Re: Code style query: multiple assignments in if/elif tree Steven D'Aprano <steve@pearwood.info> - 2014-04-01 07:29 +0000
        Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 18:49 +1100
        Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 02:29 -0600
        Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 19:56 +1100
    Re: Code style query: multiple assignments in if/elif tree David Hutto <dwightdhutto@gmail.com> - 2014-04-01 03:21 -0400
    Re: Code style query: multiple assignments in if/elif tree Chris Angelico <rosuav@gmail.com> - 2014-04-01 18:26 +1100
    Re: Code style query: multiple assignments in if/elif tree David Hutto <dwightdhutto@gmail.com> - 2014-04-01 03:34 -0400
    Re: Code style query: multiple assignments in if/elif tree David Hutto <dwightdhutto@gmail.com> - 2014-04-01 03:39 -0400
    Re: Code style query: multiple assignments in if/elif tree David Hutto <dwightdhutto@gmail.com> - 2014-04-01 03:46 -0400
    Re: Code style query: multiple assignments in if/elif tree Ian Kelly <ian.g.kelly@gmail.com> - 2014-04-01 02:55 -0600

csiph-web