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


Groups > comp.lang.python > #65270

Re: Help with some python homework...

Path csiph.com!usenet.pasdenom.info!gegeweb.org!usenet-fr.net!nerim.net!novso.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python@mrabarnett.plus.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.091
X-Spam-Evidence '*H*': 0.84; '*S*': 0.02; 'cents': 0.07; 'suppose': 0.07; 'think,': 0.07; 'subject:Help': 0.11; 'from:addr:mrabarnett.plus.com': 0.16; 'from:addr:python': 0.16; 'from:name:mrab': 0.16; 'message-id:@mrabarnett.plus.com': 0.16; 'received:192.168.1.4': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; '3.0': 0.19; 'print': 0.22; 'header:User-Agent:1': 0.23; 'replace': 0.24; 'second': 0.26; 'header:In-Reply-To:1': 0.27; 'subject:some': 0.31; 'problem': 0.35; 'subject:with': 0.35; 'no,': 0.35; 'but': 0.35; 'should': 0.36; 'starting': 0.37; 'to:addr:python-list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; "you're": 0.61; 'first': 0.61; 'here:': 0.62; 'costs': 0.63; 'for:': 0.64; 'total': 0.65; 'price': 0.69; 'price:': 0.78; '40%': 0.84; 'shipping,': 0.84; 'discount': 0.87; 'discounted': 0.95; 'wholesale': 0.96
X-CM-Score 0.00
X-CNFS-Analysis v=2.1 cv=eZmzft0H c=1 sm=1 tr=0 a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17 a=0Bzu9jTXAAAA:8 a=5FYZ9MsUIQAA:10 a=lYmbDxrgSswA:10 a=ihvODaAuJD4A:10 a=IkcTkHD0fZMA:10 a=EBOSESyhAAAA:8 a=IFej2vUWUj8A:10 a=ftVR_M1JgEfUn7HlW7gA:9 a=QEXdDO2ut3YA:10
X-AUTH mrabarnett:2500
Date Sun, 02 Feb 2014 16:38:57 +0000
From MRAB <python@mrabarnett.plus.com>
User-Agent Mozilla/5.0 (Windows NT 6.3; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
MIME-Version 1.0
To python-list@python.org
Subject Re: Help with some python homework...
References <02c4c69d-71f1-4a01-86df-d4d5a7ffb3f5@googlegroups.com> <Lr8T1n00d3bjUJS01r8V2t> <mailman.6264.1391232938.18130.python-list@python.org> <d8c2b5bd-d56d-4327-b219-85f0b304b187@googlegroups.com>
In-Reply-To <d8c2b5bd-d56d-4327-b219-85f0b304b187@googlegroups.com>
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
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.6308.1391359140.18130.python-list@python.org> (permalink)
Lines 45
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1391359140 news.xs4all.nl 2861 [2001:888:2000:d::a6]:46327
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65270

Show key headers only | View raw


On 2014-02-02 16:11, David Hutto wrote:
> price_per_book = 24.95
> discount = .40
> quantity = 60
>
The original problem says:

Suppose the cover price of a book is $24.95, but bookstores get a 40%
discount. Shipping costs  $3 for the first copy and 75 cents for each
additional copy. What is the total wholesale cost for 60 copies?

> Here:
> discounted_price = (1-discount) * price_per_book
>
> The discounted price should be price_per_book - discount
>
No, the discount of 0.40 is 40%, not 40 cents.

> shipping = 3.0 + (60 - 1) * .75
> shipping should be, I think, should be 3.0 + (quantity  * .75)
>
No, the shipping is 75 cents starting from the second copy.

> total_price = 60 * discounted_price + shipping
> replace 60 with quantity (quantity * discounted_price) + shipping
>
> print total_price, 'Total price'
>
> total_price gives:
> 945.45 Total price
> and just 24.55(price per book - discount is ) * quantity is $1473 without the shipping, so the total is way off already:
>
>
> I think the following is what you're looking for:
>
> price_per_book = 24.95
> discount = .40
> quantity = 60
> discounted_price = price_per_book-discount
> shipping = 3.0 + (quantity*.75)
> total_price = (quantity * discounted_price) + shipping
> print 'Total price: $%d' % (total_price)
> Total price: $1521
>

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


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