Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder1.xlned.com!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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.034 X-Spam-Evidence: '*H*': 0.93; '*S*': 0.00; 'string': 0.09; 'calculating': 0.09; 'formatting': 0.09; 'lost.': 0.09; 'seemed': 0.09; 'cc:addr:python-list': 0.11; 'subject:Help': 0.11; 'python': 0.11; 'jan': 0.12; '00:00:00': 0.16; '11:42': 0.16; 'docs.': 0.16; 'remainder': 0.16; 'sec': 0.16; 'seconds,': 0.16; 'uppercase': 0.16; 'subject:python': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'received:10.0.1': 0.19; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'error': 0.23; '31,': 0.24; 'case.': 0.24; 'hours,': 0.24; 'guys': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'chris': 0.29; 'am,': 0.29; 'to:no real name:2**1': 0.29; 'converting': 0.30; 'cool': 0.30; 'returned': 0.30; 'url:mailman': 0.30; 'gives': 0.31; 'code': 0.31; 'too.': 0.31; 'subject:some': 0.31; 'though.': 0.31; 'critical': 0.32; 'figure': 0.32; 'run': 0.32; 'url:python': 0.33; 'subject:with': 0.35; 'something': 0.35; 'one,': 0.35; 'but': 0.35; 'minutes,': 0.36; 'url:listinfo': 0.36; 'thanks': 0.36; "i'll": 0.36; 'received:10.0': 0.36; 'url:org': 0.36; 'should': 0.36; 'seconds': 0.37; 'so,': 0.37; 'two': 0.37; 'received:10': 0.37; 'pm,': 0.38; 'little': 0.38; 'sure': 0.39; 'url:mail': 0.40; 'how': 0.40; 'free': 0.61; 'lower': 0.61; 'back': 0.62; 'header:Message-Id:1': 0.63; 'name': 0.63; 'kind': 0.63; 'more': 0.64; 'different': 0.65; 'to:2**2': 0.65; 'to:addr:gmail.com': 0.65; 'charset:windows-1252': 0.65; 'hours': 0.66; 'minutes': 0.67; 'between': 0.67; 'below.': 0.71; 'trial': 0.83; '2014,': 0.84; 'calculations': 0.84; 'divide': 0.84; 'it\x92s': 0.84; 'i\x92d': 0.84; 'scott': 0.93 X-CT-Class: Clean X-CT-Score: 0.00 X-CT-RefID: str=0001.0A020202.52EC4A7A.003D,ss=1,re=0.000,fgs=0 X-CT-Spam: 0 X-Authority-Analysis: v=2.0 cv=aZC/a2Ut c=1 sm=1 a=MB85R812cvcrhCHz/P2OVA==:17 a=lYmbDxrgSswA:10 a=G8Uczd0VNMoA:10 a=N659UExz7-8A:10 a=kviXuzpPAAAA:8 a=IFej2vUWUj8A:10 a=pGLkceISAAAA:8 a=8AHkEIZyAAAA:8 a=P6bk2D4SxWLfyfjfLakA:9 a=pILNOxqGKmIA:10 a=MSl-tDqOz04A:10 a=4vB-4DCPJfMA:10 a=YPlSZDja-jf87_9E:21 a=NyCZZ8BWIBgh2miH:21 a=MB85R812cvcrhCHz/P2OVA==:117 X-CM-Score: 0.00 Authentication-Results: cox.net; auth=pass (PLAIN) smtp.auth=swdunning@cox.net Content-Type: text/plain; charset=windows-1252 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 18:14:31 -0700 Content-Transfer-Encoding: quoted-printable References: <02c4c69d-71f1-4a01-86df-d4d5a7ffb3f5@googlegroups.com> <8da5d692-1446-4107-9a5a-5efd91f7c051@googlegroups.com> To: Chris Angelico , neilc@norwich.edu, 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: 58 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391232938 news.xs4all.nl 2969 [2001:888:2000:d::a6]:43320 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65186 Thanks Chris! =20 So, this is what I came up with. It works, which is good but it=92s a = little different from a few things you guys had mentioned. For one, I = got the correct time by calculating the number of time run and = converting that into seconds then back out to hr:mn:sc. I didn=92t = calculate from midnight. That seemed more complicated to me because I=92d= have to figure the number of seconds from midnight to 6:52am then do = the calculations for number of seconds run until I got home, then I got = kind of lost. Also, before I forget what is the difference between / = and //? I remember something about floor division? Not sure what that = means though. Is it like a % where it gives the remainder after = dividing? Thanks again. Code below. Also, I think I found out through = a little trial and error that I had two different hours, mins, and sec = so I had to use one uppercase and one lower case. Is that frowned upon? = And should I have come up with a different name instead? SECONDS =3D 1 MINUTES =3D 60 * SECONDS HOURS =3D 60 * MINUTES time_left_house =3D 6 * HOURS + 52 * MINUTES miles_run_easy_pace =3D 2 * (8 * MINUTES + 15 * SECONDS) miles_run_fast_pace =3D 3 * (7 * MINUTES + 12 * SECONDS) time_returned_home =3D miles_run_easy_pace + miles_run_fast_pace + = time_left_house hours =3D time_returned_home // HOURS part_hour =3D time_returned_home % HOURS minutes =3D part_hour // MINUTES seconds =3D part_hour % MINUTES print "Time returned home:", hours,":", minutes,":", seconds,=94am" On Jan 31, 2014, at 5:57 PM, Chris Angelico wrote: > On Sat, Feb 1, 2014 at 11:42 AM, Scott W Dunning = wrote: >> Also, any help on how to get the hours and seconds into double digits = that would be cool too. 00:00:00 >=20 > Once you can divide the number of seconds into hours, minutes, and > seconds, you can format them like this: >=20 > time =3D "%02d:%02d:%02d" % (hours, minutes, seconds) >=20 > I'll give you that one for free because I don't think it's > particularly critical to your course, but it will look better that way > :) Look up the string formatting features of Python in the docs. >=20 > ChrisA > --=20 > https://mail.python.org/mailman/listinfo/python-list