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


Groups > comp.lang.python > #65981

Re: Simple % question

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.026
X-Spam-Evidence '*H*': 0.95; '*S*': 0.00; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'subject:question': 0.10; 'question.': 0.14; 'received:80.91.229.3': 0.16; 'received:97': 0.16; 'received:plane.gmane.org': 0.16; 'wrote:': 0.18; 'header:User- Agent:1': 0.23; 'header:X-Complaints-To:1': 0.27; 'header:In- Reply-To:1': 0.27; 'function': 0.29; 'christopher': 0.36; 'from:addr:live.com': 0.36; 'subject:Simple': 0.36; 'to:addr :python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'numbers': 0.61; 'simple': 0.61; 'times': 0.62; 'don\xe2\x80\x99t': 0.91; 'scott': 0.93
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Christopher Welborn <cjwelborn@live.com>
Subject Re: Simple % question
Date Tue, 11 Feb 2014 19:51:41 -0600
References <63EBCBF1-6C1B-4B8B-9D4A-0567CBDA978A@cox.net>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 8bit
X-Gmane-NNTP-Posting-Host 97-82-32-107.dhcp.mtgm.al.charter.com
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.2.0
In-Reply-To <63EBCBF1-6C1B-4B8B-9D4A-0567CBDA978A@cox.net>
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.6718.1392169918.18130.python-list@python.org> (permalink)
Lines 34
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1392169918 news.xs4all.nl 2849 [2001:888:2000:d::a6]:59112
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:65981

Show key headers only | View raw


On 02/11/2014 07:06 PM, Scott W Dunning wrote:
> I just have a simple question.  I don’t understand why 1%10  = 1?
>
>
  I think because 1 is evenly divisible by 10 exactly 0 times with a 1
remainder. I mean int(1 / 10) == 0, with a 1 remainder.
The same is true for all numbers leading up to 10.

for i in range(12):
     print('{} % 10 == {}'.format(i, i % 10))

0 % 10 == 0
1 % 10 == 1
2 % 10 == 2
3 % 10 == 3
4 % 10 == 4
5 % 10 == 5
6 % 10 == 6
7 % 10 == 7
8 % 10 == 8
9 % 10 == 9
10 % 10 == 0
11 % 10 == 1

You can see that with the divmod() function also.



-- 
\¯\      /¯/\
  \ \/¯¯\/ / / Christopher Welborn (cj)
   \__/\__/ /  cjwelborn at live·com
    \__/\__/   http://welbornprod.com

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


Thread

Re: Simple % question Christopher Welborn <cjwelborn@live.com> - 2014-02-11 19:51 -0600

csiph-web