Help with some python homework...

David Hutto dwightdhutto at gmail.com
Sun Feb 2 17:36:11 CET 2014


On Sunday, February 2, 2014 11:11:07 AM UTC-5, David Hutto wrote:
> price_per_book = 24.95
> 
> discount = .40
> 
> quantity = 60
> 
> 
> 
> Here:
> 
> discounted_price = (1-discount) * price_per_book
> 
> 
> 
> The discounted price should be price_per_book - discount
> 
> 
> 
> shipping = 3.0 + (60 - 1) * .75
> 
> shipping should be, I think, should be 3.0 + (quantity  * .75)
> 
> 
> 
> 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

My bad, I thought you were using $0.40 
as a discount



More information about the Python-list mailing list