Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #65991

Re: Simple % question

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin2!goblin.stu.neva.ru!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.056
X-Spam-Evidence '*H*': 0.89; '*S*': 0.00; 'subject:question': 0.10; 'cc:addr:python-list': 0.11; 'python': 0.11; 'ah,': 0.16; 'division,': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'means.': 0.16; 'remainder': 0.16; 'simple.': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'feb': 0.22; 'cc:addr:python.org': 0.22; 'looks': 0.24; 'question': 0.24; 'cc:2**0': 0.24; 'this:': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'message-id:@mail.gmail.com': 0.30; 'work.': 0.31; 'yes.': 0.31; 'another': 0.32; 'quite': 0.32; 'actual': 0.34; 'sense': 0.34; 'there,': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'in.': 0.36; 'subject:Simple': 0.36; 'so,': 0.37; 'pm,': 0.38; 'expect': 0.39; '12,': 0.39; 'changed': 0.39; 'even': 0.60; 'is.': 0.60; 'simply': 0.61; "you're": 0.61; 'real': 0.63; '2014,': 0.84; '2:30': 0.84; 'to:none': 0.92; 'scott': 0.93; 'tied': 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=RF+LmIk7oV05LuCwxsgUZNsiHOkjrKE1QBOc9ktBbzA=; b=hQQW5o3+AVuCmG9QQpFq2WklHILTnv775gX6itiCoVhD/A04e2z38c/2Fj3cgaSLWD rt3yP+0TgP45SLbXP632ZB6BY0qYEmbd6SIo829s3MxMMfY3dv9LUgxWDUpIQMro51H1 izrJt46WeavC8Tq4slqvWf3JfgIa+oNgPlXkhxILOASWotS93V8Y3Lty3JCWiqpiji7W tVsTTLc5oXXEfSTTxXbsKy6QTobhXZxaYOQGf5qE4r12aWvTPWhVnZFEIm/A4y2vhOtr KOKev6bwG87j5EDI68usuPgi2+fB1UQNDeIek4CDSaFxOmb0PsSTq1cRUZqrOey4CifX h9Gg==
MIME-Version 1.0
X-Received by 10.66.66.234 with SMTP id i10mr36457335pat.127.1392176417128; Tue, 11 Feb 2014 19:40:17 -0800 (PST)
In-Reply-To <4ED77821-6237-484F-A6BF-5B970CC6560B@cox.net>
References <63EBCBF1-6C1B-4B8B-9D4A-0567CBDA978A@cox.net> <4ED77821-6237-484F-A6BF-5B970CC6560B@cox.net>
Date Wed, 12 Feb 2014 14:40:17 +1100
Subject Re: Simple % question
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <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 <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.6723.1392176426.18130.python-list@python.org> (permalink)
Lines 20
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392176426 news.xs4all.nl 2838 [2001:888:2000:d::a6]:37531
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65991

Show key headers only | View raw


On Wed, Feb 12, 2014 at 2:30 PM, Scott W Dunning <swdunning@cox.net> wrote:
> On Feb 11, 2014, at 6:36 PM, Chris Angelico <rosuav@gmail.com> wrote:
>>
>> 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:
>
> Yeah I understand what the % means.  It just confused me that 1%10 was 1.  In my thought process it just didn’t work.  1/10= .1 and I just didn’t see where the remainder of 1 came in.
>

Ah, yes. When Python 2 -> Python 3 changed the meaning of / the
meaning of % got tied instead to //. But if you think about it, with
the floating-point result you're describing there, it simply makes no
sense to even ask what the remainder is. So, if you're going to use %,
use //, and then it all makes sense.

ChrisA

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: Simple % question Chris Angelico <rosuav@gmail.com> - 2014-02-12 14:40 +1100

csiph-web