Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #65272
| Path | csiph.com!newsfeed.hal-mli.net!feeder3.hal-mli.net!newsfeed.hal-mli.net!feeder1.hal-mli.net!peer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!post01.iad.highwinds-media.com!fx14.am4.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset=utf-8; format=flowed; delsp=yes |
| Newsgroups | comp.lang.python |
| Subject | Re: Help with some python homework... |
| References | <02c4c69d-71f1-4a01-86df-d4d5a7ffb3f5@googlegroups.com> <Lr8T1n00d3bjUJS01r8V2t> <mailman.6264.1391232938.18130.python-list@python.org> |
| MIME-Version | 1.0 |
| Content-Transfer-Encoding | 8bit |
| From | "Rhodri James" <rhodri@wildebst.org.uk> |
| Organization | The Wildebestiary |
| Message-ID | <op.xanzjfvv5079vu@gnudebeest> (permalink) |
| User-Agent | Opera Mail/12.16 (Linux) |
| Lines | 29 |
| NNTP-Posting-Host | 81.97.70.240 |
| X-Complaints-To | http://netreport.virginmedia.com |
| X-Trace | 1391361305 81.97.70.240 (Sun, 02 Feb 2014 17:15:05 UTC) |
| NNTP-Posting-Date | Sun, 02 Feb 2014 17:15:05 UTC |
| Date | Sun, 02 Feb 2014 17:15:05 -0000 |
| X-Received-Bytes | 1990 |
| X-Received-Body-CRC | 3942424093 |
| Xref | csiph.com comp.lang.python:65272 |
Show key headers only | View raw
On Sat, 01 Feb 2014 05:18:34 -0000, Scott W Dunning <swdunning@cox.net>
wrote:
> Any chance you guys could help with another question I have? Below is a
> code to a different problem. The only thing I don’t understand is why
> when calculating the 'discounted price’ you have to subtract 1? Thanks
> again guys!
>
> price_per_book = 24.95
> discount = .40
> quantity = 60
> discounted_price = (1-discount) * price_per_book
> shipping = 3.0 + (60 - 1) * .75
> total_price = 60 * discounted_price + shipping
> print total_price, 'Total price'
The thing that is confusing you is that "discounted_price" is conflating
several steps into one. Think of it like this:
* "discount" is the discount rate; in this case meaning that a book costs
40% less than its list price ("price_per_book").
* In other words, the book costs "discount * price_per_book" less than
its list price.
* So the book costs "price_per_book - (discount * price_per_book)" after
applying the discount.
* refactoring, that's "(1 - discount) * price_per_book." Ta da!
--
Rhodri James *-* Wildebeest Herder to the Masses
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Help with some python homework... scottwd80@gmail.com - 2014-01-30 21:12 -0800
Re: Help with some python homework... Chris Angelico <rosuav@gmail.com> - 2014-01-31 16:30 +1100
Re: Help with some python homework... sjud9227 <scottwd80@gmail.com> - 2014-01-30 22:24 -0800
Re: Help with some python homework... Chris Angelico <rosuav@gmail.com> - 2014-01-31 17:38 +1100
Re: Help with some python homework... sjud9227 <scottwd80@gmail.com> - 2014-01-30 22:48 -0800
Re: Help with some python homework... Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-01-31 21:17 +1300
Re: Help with some python homework... Chris Angelico <rosuav@gmail.com> - 2014-01-31 19:30 +1100
Re: Help with some python homework... Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-01-31 23:46 +1300
Re: Help with some python homework... Chris Angelico <rosuav@gmail.com> - 2014-02-01 11:57 +1100
Re: Help with some python homework... Chris Angelico <rosuav@gmail.com> - 2014-02-01 12:34 +1100
Re: Help with some python homework... David <bouncingcats@gmail.com> - 2014-02-01 14:17 +1100
Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 18:14 -0700
Re: Help with some python homework... Denis McMahon <denismfmcmahon@gmail.com> - 2014-02-01 19:32 +0000
Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 17:12 -0800
Re: Help with some python homework... Larry Hudson <orgnut@yahoo.com> - 2014-02-02 23:48 -0800
Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 17:46 -0700
Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 17:42 -0700
Re: Help with some python homework... David <bouncingcats@gmail.com> - 2014-02-01 17:13 +1100
Re: Help with some python homework... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-01 10:44 -0500
Re: Help with some python homework... Neil Cerutti <neilc@norwich.edu> - 2014-01-31 13:51 +0000
Re: Help with some python homework... Denis McMahon <denismfmcmahon@gmail.com> - 2014-02-01 03:02 +0000
Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 17:35 -0700
Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 22:18 -0700
Re: Help with some python homework... Denis McMahon <denismfmcmahon@gmail.com> - 2014-02-01 19:45 +0000
Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 08:11 -0800
Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 08:36 -0800
Re: Help with some python homework... MRAB <python@mrabarnett.plus.com> - 2014-02-02 16:38 +0000
Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 08:57 -0800
Re: Help with some python homework... Denis McMahon <denismfmcmahon@gmail.com> - 2014-02-02 17:43 +0000
Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 10:09 -0800
Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 11:08 -0800
Re: Help with some python homework... David Hutto <dwightdhutto@gmail.com> - 2014-02-02 11:21 -0800
Re: Help with some python homework... "Rhodri James" <rhodri@wildebst.org.uk> - 2014-02-02 17:15 +0000
Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 22:04 -0700
Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 17:07 -0700
Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-01-31 22:19 -0700
Re: Help with some python homework... Dennis Lee Bieber <wlfraed@ix.netcom.com> - 2014-02-01 10:50 -0500
Re: Help with some python homework... Scott W Dunning <swdunning@cox.net> - 2014-02-01 23:06 -0700
csiph-web