Help with some python homework...

David Hutto dwightdhutto at gmail.com
Sun Feb 2 11:11:07 EST 2014


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



More information about the Python-list mailing list