# Help with some python homework...

Scott W Dunning swdunning at cox.net
Sat Feb 1 06:19:24 CET 2014

```If you’re interested in what the problem is here it is…

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?

On Jan 31, 2014, at 10:18 PM, Scott W Dunning <swdunning at 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'
>
> Scott
>
>
>
> On Jan 31, 2014, at 8:02 PM, Denis McMahon <denismfmcmahon at gmail.com> wrote:
>
>> On Thu, 30 Jan 2014 21:12:19 -0800, scottwd80 wrote:
>>
>>> Here is the question that was asked and below that I'll paste the code I
>>> have so far.
>>
>> The following is a reasonably but not highly obfuscated short solution to
>> the problem set in python 2.7. With a bit of luck, after each lesson of
>> your course, you'll be able to understand a bit more of how it works.
>>
>> M=60;H=M*60
>> def s(h,m,s): return h*H+m*M+s
>> def hms(s): return (int(s/H),int((s%H)/M),s%M)
>> (a,b,c)=hms(s(6,52,0)+3*s(0,7,12)+2*s(0,8,15))
>> print "{:02d}:{:02d}:{:02d}".format(a,b,c)
>>
>> When you can write a short paragraph describing what each line of the
>> program does, you'll be on your way to understanding a few of the
>> structures, syntaxes and mechanisms of python.
>>
>> Or you could show it to your lecturer or a TA and say it was suggested
>> that you ask her or him to work through it with you.
>>
>> --
>> Denis McMahon, denismfmcmahon at gmail.com
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20140131/2ffc6cc2/attachment.html>
```