Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed2.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.017 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'base.': 0.05; 'subject:Python': 0.06; 'subject:help': 0.08; '40,': 0.09; 'lost.': 0.09; 'subject:modules': 0.09; 'cc:addr:python-list': 0.11; '60,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'once.': 0.16; 'remainder': 0.16; 'seconds.': 0.16; 'wrote:': 0.18; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'mon,': 0.24; 'cc:2**0': 0.24; 'header:In-Reply-To:1': 0.27; 'correct': 0.29; 'sets': 0.30; 'message-id:@mail.gmail.com': 0.30; 'up:': 0.31; 'probably': 0.32; 'subject:with': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'next': 0.36; 'changing': 0.37; 'seconds': 0.37; 'pm,': 0.38; 'little': 0.38; 'does': 0.39; 'how': 0.40; 'first': 0.61; 'here': 0.66; 'line,': 0.68; 'clearer': 0.84; 'confusing': 0.84; 'divide': 0.84; 'it\xe2\x80\x99s': 0.84; 'to:none': 0.92; 'scott': 0.93 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=qkXoh7mAcnyE4acvzd2jyfiUISwkR2RSAooQRXgFB3A=; b=You1hGdARUbfyRRfy4dhi0dLOfmO2Xj6vj88MZwDTIvvbXI6QrfwmusWP/K+Fl5KNt HivsQC+JdlRYYd1s41/0549/9qH5HQuWumg7EXyMD+D1R/g9MY6/X3pNqdJb3AxFaPQb JR3vpEZgeALbmXxJ5DjILg07LLFngSHafvM+5llRFg8ypcqC2YDH3Db8LeeiPcfilY7w tfrTrdTiNqVXsdQKKM722qCebHisOvR/0eZcSDH34nVIjkasVAxcdHaPp+o6+TfXhC6K dp+7VDUim6GzA3sb5BX+yoOGN43xTusY0rGpiKxUufBLsniO/0kK2c0JH7vkQPcPZ/iV Wkrw== MIME-Version: 1.0 X-Received: by 10.68.182.165 with SMTP id ef5mr810281pbc.169.1392006655257; Sun, 09 Feb 2014 20:30:55 -0800 (PST) In-Reply-To: <972E1362-8C9D-47BC-BAD7-A0CA754C8D84@cox.net> References: <032F2E23-6983-4710-B087-C1771B66C3EF@cox.net> <635C857D-1F7A-4F95-B3A7-F1A3C69BF137@cox.net> <1DA52F3B-CE00-4E47-BE84-C07482966FD7@cox.net> <972E1362-8C9D-47BC-BAD7-A0CA754C8D84@cox.net> Date: Mon, 10 Feb 2014 15:30:55 +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: 25 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392006658 news.xs4all.nl 2844 [2001:888:2000:d::a6]:55598 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65799 On Mon, Feb 10, 2014 at 3:17 PM, Scott W Dunning wrote: > How to do it from the small end up: > > time =3D int(raw_input("Enter number of seconds: ")) > seconds =3D time % 60 > > So here it takes say 1000000 and divides it by 60 to put in seconds and > spits out the remainder? 1000000 / 60 is approximately 16666 with a > remainder of about 40, which would be the correct amount for seconds. Fr= om > there I get a little lost. > > time /=3D 60 > > Then we take the remainder (40) from above and divide that by 60? Alread= y > it=E2=80=99s confusing me. The first part just spits out the remainder, without changing the base. It'll set seconds to 40 (exactly, not about), but time is still 1000000. Then in the next line, we divide time by 60, which sets it to that quotient (16666). This is why it's probably clearer to use divmod, which does both halves (quotient and remainder) at once. ChrisA