Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!news.albasani.net!newsreader4.netcologne.de!news.netcologne.de!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed4.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.057 X-Spam-Evidence: '*H*': 0.89; '*S*': 0.00; 'broken': 0.04; 'subject:Python': 0.06; 'remaining': 0.07; 'subject:help': 0.08; 'augmented': 0.09; 'bits': 0.09; 'subject:modules': 0.09; 'weeks,': 0.09; 'cc:addr:python-list': 0.11; '"in': 0.16; '......': 0.16; '24,': 0.16; '3600,': 0.16; '60,': 0.16; 'brightest': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'inclined': 0.16; 'mildly': 0.16; 'nerds,': 0.16; 'seconds,': 0.16; 'seconds.': 0.16; 'wrote:': 0.18; 'result.': 0.19; 'things.': 0.19; 'feb': 0.22; 'minutes.': 0.22; 'cc:addr:python.org': 0.22; 'print': 0.22; 'certainly': 0.24; 'days,': 0.24; 'hours,': 0.24; 'recognize': 0.24; 'guys': 0.24; 'cc:2**0': 0.24; 'first,': 0.26; 'second': 0.26; 'least': 0.26; 'values': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'correct': 0.29; '[1]': 0.29; 'skills.': 0.29; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'work.': 0.31; 'getting': 0.31; 'easier': 0.31; 'evil': 0.31; 'strip': 0.31; 'anyone': 0.31; 'figure': 0.32; 'weeks': 0.32; 'run': 0.32; 'alone': 0.33; "i'd": 0.34; 'subject:with': 0.35; 'advice': 0.35; 'no,': 0.35; "who's": 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; '(we': 0.36; 'campaign': 0.36; 'minutes,': 0.36; 'up!': 0.36; 'next': 0.36; 'thanks': 0.36; 'similar': 0.36; 'half': 0.37; 'seconds': 0.37; 'step': 0.37; 'being': 0.38; 'pm,': 0.38; 'that,': 0.38; 'help,': 0.39; 'sure': 0.39; 'enough': 0.39; 'how': 0.40; 'days': 0.60; 'most': 0.60; 'break': 0.61; "you're": 0.61; 'first': 0.61; 'back': 0.62; "you'll": 0.62; 'our': 0.64; 'teaching': 0.64; 'taking': 0.65; 'movie': 0.65; 'hours': 0.66; 'here': 0.66; 'minutes': 0.67; 'it!': 0.67; 'answer.': 0.68; 'effective.': 0.68; 'nobody': 0.68; 'helping': 0.70; 'power': 0.76; 'etc,': 0.84; 'i\xe2\x80\x99ll': 0.84; 'maths': 0.84; 'out!': 0.84; 'sight': 0.84; 'don\xe2\x80\x99t': 0.91; 'dozen': 0.91; 'step.': 0.91; 'works!': 0.91; 'you\xe2\x80\x99re': 0.91; 'to:none': 0.92; 'children.': 0.93; 'scott': 0.93; 'online,': 0.96 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=86Zxw6Aq/dCLwMVHwnk7BBy6R1fzFijT+IerX3MLktI=; b=geNBVW+CR6aM8+mU47QirzGFe6Azvq0AJtA/U3ZoVDOIo2iKmhEqFIGf7Y0ND6pWk9 RXMbJ0VNw/GOyUzkMXnUYhXb4ZvnOBtkkvEWn7QCLnN0Ca8rBLnmBhZMrAf1qtBQxXY3 wgvrI/Jjc562J7vNMGzb1n6+JbIZhI/EdZa7bH9mu6nkzHmR81Z5pEIEOxoDYgPy6lUk hlgDdFIq2n/6hYSpiSKTZDO81n+8FWHaFnr+sLey5O/MBgQKk04DB9HTCAGTWEQlzncH gmyuHXSwuayxvC6gUhrjjOqCRAZTXatYoOTHIIKPxgP+24dCITjrKyWuvoI15Wc0n9GJ jZSw== MIME-Version: 1.0 X-Received: by 10.68.143.231 with SMTP id sh7mr29321777pbb.7.1391910387274; Sat, 08 Feb 2014 17:46:27 -0800 (PST) In-Reply-To: <1DA52F3B-CE00-4E47-BE84-C07482966FD7@cox.net> References: <032F2E23-6983-4710-B087-C1771B66C3EF@cox.net> <635C857D-1F7A-4F95-B3A7-F1A3C69BF137@cox.net> <1DA52F3B-CE00-4E47-BE84-C07482966FD7@cox.net> Date: Sun, 9 Feb 2014 12:46:27 +1100 Subject: Re: Python 2.7.6 help with modules From: Chris Angelico Cc: "python-list@python.org" Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable 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: 75 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1391910396 news.xs4all.nl 2871 [2001:888:2000:d::a6]:43854 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65704 On Sun, Feb 9, 2014 at 12:21 PM, Scott W Dunning wrote: > I figured it out! Thanks Chris! Taking it one step at a time with the f= ive digit number really helped me to see how to break it all up! Are you a= teacher? I appreciate the help and the patients! I like that you don=E2= =80=99t just give me the answer that you break it down and help me so that = I can figure it out on my own! Thanks to all of you for all of your help, = you guys are helping me a lot and I really appreciate it! > Awesome! No, I'm not a teacher by profession, but I was homeschooled, and since I'm the second of seven children [1], I got used to teaching things to my siblings. Also, every week I run a Dungeons and Dragons campaign online, which requires similar skills. (Teaching maths is way easier than getting my players to figure out some puzzles. I had no idea that, in a group of half a dozen nerds, nobody would recognize this broken text: "In brightest day, in blackest night / No evil ...... sight / Let .... worship .... mi.... / .... my power .... tern...." - I'd have thought the first line alone would be enough for anyone who's at least mildly nerdy and/or geeky.) (We start in fifteen minutes. Want to come watch? Just telnet to minstrelhall.com port 221!) > Here is how I did it if you=E2=80=99re curious.=E2=80=A6. > > seconds =3D raw_input("Enter the number of seconds:") > seconds =3D int(seconds) > weeks =3D seconds/604800 > weeks_rem =3D seconds % 604800 > days =3D weeks_rem / 86400 > days_rem =3D seconds % 86400 > hours =3D days_rem / 3600 > hours_rem =3D seconds % 3600 > minutes =3D hours_rem / 60 > minutes_rem =3D seconds % 60 > seconds =3D minutes_rem % 60 > > print weeks, 'weeks', days, 'days', hours, 'hours', minutes, 'minutes', s= econds, 'seconds' > > Not sure if that=E2=80=99s the correct way to do it but it works! If th= ere is any other advice I=E2=80=99ll take it. That's certainly effective. It's going to give you the right result. I would be inclined to start from the small end and strip off the seconds first, then the minutes, etc, because then you're working with smaller divisors (60, 60, 24, 7 instead of 604800, 86400, 3600, 60); most people will understand that a week is 7 days, but only people who work with DNS will know that it's 604800 seconds. But both work. You'll also note that you're trimming off bits and leaving "residual seconds". I would put all the "_rem" values back into "seconds", which would let you use augmented assignment: weeks =3D seconds/604800 seconds %=3D 604800 days =3D seconds / 86400 seconds %=3D 86400 hours =3D seconds / 3600 seconds %=3D 3600 minutes =3D seconds / 60 seconds %=3D 60 This emphasizes that you're stripping components off and keeping the number of remaining seconds for the next step. But that's pretty minor. Main thing is, you know what you're doing; you have to not just get the right answer, but know WHY you get that answer. ChrisA [1] Our father's not a captain, but there's still nothing about being a non-captain with seven children. And that movie is definitely one of our favorite things.