Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed3.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.029 X-Spam-Evidence: '*H*': 0.94; '*S*': 0.00; 'python.': 0.02; 'cents': 0.07; 'suppose': 0.07; 'calculating': 0.09; 'guys!': 0.09; 'works.': 0.09; 'cc:addr:python-list': 0.11; 'subject:Help': 0.11; 'python': 0.11; 'def': 0.12; 'jan': 0.12; 'does,': 0.16; 'luck,': 0.16; 'reasonably': 0.16; 'subtract': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'bit': 0.19; '3.0': 0.19; 'received:10.0.1': 0.19; 'thu,': 0.19; '>>>': 0.22; 'email addr:gmail.com>': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; '31,': 0.24; 'guys': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'cc:no real name:2**0': 0.24; 'skip:" 30': 0.26; 'suggested': 0.26; 'header:In-Reply- To:1': 0.27; 'skip:( 40': 0.30; 'skip:( 20': 0.30; 'url:mailman': 0.30; 'asked': 0.31; 'code': 0.31; 'subject:some': 0.31; 'you\x92re': 0.31; 'another': 0.32; 'url:python': 0.33; 'could': 0.34; 'problem': 0.35; 'subject:with': 0.35; 'problem.': 0.35; 'but': 0.35; 'url:listinfo': 0.36; 'thanks': 0.36; "i'll": 0.36; 'received:10.0': 0.36; 'url:org': 0.36; 'received:10': 0.37; 'pm,': 0.38; 'short': 0.38; 'url:mail': 0.40; 'how': 0.40; 'skip:u 10': 0.60; 'first': 0.61; 'you.': 0.62; "you'll": 0.62; 'header :Message-Id:1': 0.63; 'email addr:gmail.com': 0.63; 'show': 0.63; 'costs': 0.63; 'more': 0.64; 'total': 0.65; 'different': 0.65; 'chance': 0.65; 'to:2**2': 0.65; 'to:addr:gmail.com': 0.65; 'charset:windows-1252': 0.65; 'here': 0.66; 'price': 0.69; '2.7.': 0.84; '2014,': 0.84; '40%': 0.84; 'have?': 0.84; 'received:68.230.241.237': 0.84; 'discount': 0.87; 'scott': 0.93; 'wholesale': 0.96 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020201.52EC83DE.0009,ss=1,re=0.000,fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=2.0 cv=BJhtWisG c=1 sm=1 a=MB85R812cvcrhCHz/P2OVA==:17 a=lYmbDxrgSswA:10 a=G8Uczd0VNMoA:10 a=kviXuzpPAAAA:8 a=IFej2vUWUj8A:10 a=pGLkceISAAAA:8 a=8AHkEIZyAAAA:8 a=tS986biw7FQ-4zBqorYA:9 a=pILNOxqGKmIA:10 a=4vB-4DCPJfMA:10 a=MSl-tDqOz04A:10 a=IgrzjyipTbL_GNOFQNYA:9 a=_W_S_7VecoQA:10 a=MB85R812cvcrhCHz/P2OVA==:117 X-CM-Score: 0.00 Authentication-Results: cox.net; auth=pass (PLAIN) smtp.auth=swdunning@cox.net Content-Type: multipart/alternative; boundary="Apple-Mail=_9E84C667-1E34-4C0B-8A94-AF7BF9D12A23" Mime-Version: 1.0 (Mac OS X Mail 7.1 \(1827\)) Subject: Re: Help with some python homework... From: Scott W Dunning In-Reply-To: Date: Fri, 31 Jan 2014 22:19:24 -0700 References: <02c4c69d-71f1-4a01-86df-d4d5a7ffb3f5@googlegroups.com> To: Denis McMahon , Chris Angelico , Neil Cerutti , greg.ewing@canterbury.ac.nz X-Mailer: Apple Mail (2.1827) X-Mailman-Approved-At: Sat, 01 Feb 2014 06:35:37 +0100 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 131 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391232939 news.xs4all.nl 2973 [2001:888:2000:d::a6]:43361 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65194 --Apple-Mail=_9E84C667-1E34-4C0B-8A94-AF7BF9D12A23 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=windows-1252 If you=92re interested in what the problem is here it is=85 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 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=92t understand is = why when calculating the 'discounted price=92 you have to subtract 1? = Thanks again guys! =20 >=20 > price_per_book =3D 24.95 > discount =3D .40 > quantity =3D 60 > discounted_price =3D (1-discount) * price_per_book > shipping =3D 3.0 + (60 - 1) * .75 > total_price =3D 60 * discounted_price + shipping > print total_price, 'Total price' >=20 > Scott=20 >=20 >=20 >=20 > On Jan 31, 2014, at 8:02 PM, Denis McMahon = wrote: >=20 >> On Thu, 30 Jan 2014 21:12:19 -0800, scottwd80 wrote: >>=20 >>> Here is the question that was asked and below that I'll paste the = code I >>> have so far. >>=20 >> The following is a reasonably but not highly obfuscated short = solution to=20 >> the problem set in python 2.7. With a bit of luck, after each lesson = of=20 >> your course, you'll be able to understand a bit more of how it works. >>=20 >> M=3D60;H=3DM*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)=3Dhms(s(6,52,0)+3*s(0,7,12)+2*s(0,8,15)) >> print "{:02d}:{:02d}:{:02d}".format(a,b,c) >>=20 >> When you can write a short paragraph describing what each line of the=20= >> program does, you'll be on your way to understanding a few of the=20 >> structures, syntaxes and mechanisms of python. >>=20 >> Or you could show it to your lecturer or a TA and say it was = suggested=20 >> that you ask her or him to work through it with you. >>=20 >> --=20 >> Denis McMahon, denismfmcmahon@gmail.com >> --=20 >> https://mail.python.org/mailman/listinfo/python-list >=20 --Apple-Mail=_9E84C667-1E34-4C0B-8A94-AF7BF9D12A23 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=windows-1252 If = you=92re interested in what the problem is here it = is=85

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@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=92t understand is why when calculating the 'discounted price=92 = you have to subtract 1?  Thanks again guys! =  

price_per_book =3D 24.95
discount =3D .40
quantity =3D= 60
discounted_price =3D (1-discount) * price_per_book
shipping =3D = 3.0 + (60 - 1) * .75
total_price =3D 60 * discounted_price + = shipping
print total_price, 'Total price'

Scott =



On Jan 31, 2014, at 8:02 PM, Denis McMahon <denismfmcmahon@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=3D60;H=3DM*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)=3Dhms(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@gmail.com
-= -
https://mail= .python.org/mailman/listinfo/python-list


= --Apple-Mail=_9E84C667-1E34-4C0B-8A94-AF7BF9D12A23--