Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4.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.016 X-Spam-Evidence: '*H*': 0.97; '*S*': 0.00; 'operator': 0.03; 'operator,': 0.09; 'subject:question': 0.10; 'cc:addr:python- list': 0.11; 'python': 0.11; 'question.': 0.14; 'division,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'help?': 0.16; 'integers,': 0.16; 'remainder': 0.16; 'simple.': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'feb': 0.22; '>>>': 0.22; 'cc:addr:python.org': 0.22; 'integer': 0.24; 'looks': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In- Reply-To:1': 0.27; 'rest': 0.29; 'message-id:@mail.gmail.com': 0.30; 'gives': 0.31; '(usually': 0.31; 'font': 0.31; 'another': 0.32; 'quite': 0.32; '-----': 0.33; 'actual': 0.34; 'received:google.com': 0.35; 'subject:Simple': 0.36; 'two': 0.37; 'pm,': 0.38; 'anything': 0.39; 'expect': 0.39; 'does': 0.39; '12,': 0.39; 'called': 0.40; 'is.': 0.60; 'numbers': 0.61; 'simple': 0.61; 'back': 0.62; 'real': 0.63; 'fact,': 0.69; 'don\xe2\x80\x99t': 0.91; 'numbers:': 0.91; '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=yxQpxMI+hCMt50g4FLpJeE55OPkBtdroBFMygcRq0EA=; b=A5ddY8hFE4ObfQxNZySHX8t5/XaHqPwXaVrnh+9CZ+j5dK4YDS0TxZXwH7pIgww94Y bRCLnPqIxw4c9ALsl3U1OGh+o4vt/hBowlJ4jd8Xvnx7IJsGSTXh8S1gU9fQLDfq9nqS n/2FQBAYciEjaBG/ghziqBOZwanrZzOJte2I8yE33B74WY07oeHG3gBgEWiI7tk/zDqt vUpTkpVya7u2HJQEIRFgLNafLPrKU3EOmnVRYk/mJ4eqRduacF9kLlVALA9tzF+eBAEw qpOxQu7DBa9SnnTl9TGxG7++UegHpKuzN7kZlSUSPxzxMPpNzfIb+yifbtZM1Yq+HiUt 2hBg== MIME-Version: 1.0 X-Received: by 10.66.164.229 with SMTP id yt5mr36449537pab.67.1392168997993; Tue, 11 Feb 2014 17:36:37 -0800 (PST) In-Reply-To: <63EBCBF1-6C1B-4B8B-9D4A-0567CBDA978A@cox.net> References: <63EBCBF1-6C1B-4B8B-9D4A-0567CBDA978A@cox.net> Date: Wed, 12 Feb 2014 12:36:37 +1100 Subject: Re: Simple % question 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: 50 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1392169001 news.xs4all.nl 2850 [2001:888:2000:d::a6]:50593 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:65979 On Wed, Feb 12, 2014 at 12:06 PM, Scott W Dunning wrote= : > I just have a simple question. I don=E2=80=99t understand why 1%10 =3D = 1? The real question is: What do you expect that symbol to mean? Its actual meaning is quite simple. In long division, dividing one number by another looks like this: 86528 ____________ 31415 ) 2718281828 251320 ------ 205081 188490 ------ 165918 157075 ------ 88432 62830 ----- 256028 251320 ------ 4708 (Monospaced font required here.) 2718281828 is the dividend; 31415 is the divisor. They're the numbers we started with. At the top, we get the quotient, 86528, and down the bottom, the remainder, 4708. Now let's ask Python about those numbers: >>> 2718281828 // 31415 86528 >>> 2718281828 % 31415 4708 That's all it is. The // operator, when given two integers, will give back an integer which is the quotient. The % operator (usually called "modulo"), given the same two integers, gives you back the remainder. With the dividend smaller than the divisor, your quotient is zero and your remainder is the whole rest of the number; so 1 % 10 is 1. In fact, 1 % anything greater than 1 will be 1. Does that help? ChrisA