Path: csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.freenet.ag!news2.euro.net!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.026 X-Spam-Evidence: '*H*': 0.95; '*S*': 0.00; "subject:' ": 0.07; 'subject:help': 0.08; 'subject:using': 0.09; 'def': 0.12; 'random': 0.14; 'ah!': 0.16; 'better!!': 0.16; 'dice': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'hmm.': 0.16; 'sense:': 0.16; 'subject: \n ': 0.16; 'subject:python': 0.16; 'wrote:': 0.18; 'adds': 0.24; 'header:In- Reply-To:1': 0.27; 'leave': 0.29; 'am,': 0.29; 'subject:list': 0.30; 'message-id:@mail.gmail.com': 0.30; 'question:': 0.31; 'know.': 0.32; 'received:209.85': 0.35; 'common': 0.35; 'received:209.85.220': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'received:209': 0.37; 'to:addr:python-list': 0.38; 'does': 0.39; 'to:addr:python.org': 0.39; 'number,': 0.60; 'times': 0.62; 'skip:n 10': 0.64; 'more': 0.64; '26,': 0.68; 'conclude': 0.84; 'random,': 0.84; 'carlos': 0.91; '2013': 0.98 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:to :content-type; bh=szT/YXD0gsWngzK9dV+Dbd2lftpBgApHw5oHHOsvfvw=; b=T+hPcenxS1wN8bb24tNKJXZAEz4FNqijcEYD5p0DmkVqc58O7vmMyIO1BhNjYaX4v4 dhdNFTUPNQkrPTdHpzSYpB7f1TLWlDz0h/vGMCzlaUeanNhOjjcMO0jufUHS457ZRA3E FQIfNFYS0X5uy5EaaFKCZiSiQQjWpNqFg0WX8p5jG4xJV51tRPoz2ZlyVNzQtVv0h1eL XWwXgKnzoFdoLw7TAGvts5AezTk7HP9TTktO8E67iIo92BwhR3voqAxpJyqq15vfE3uo QllOe3iM0sMBZFsxC0qxcoA+PKYado7de2kFyevlLEy5wVxAbzpl3LvMr9ZCwckt3tEd HHZQ== MIME-Version: 1.0 X-Received: by 10.58.208.228 with SMTP id mh4mr11611951vec.23.1369502624306; Sat, 25 May 2013 10:23:44 -0700 (PDT) In-Reply-To: References: <78192328-b31b-49d9-9cd6-ec742c092a29@googlegroups.com> <39ac7437-857e-483f-998c-8162c1039933@googlegroups.com> <51a052d1$0$6599$c3e8da3$5496439d@news.astraweb.com> <74e33270-a79a-4878-a400-8a6cda6637b2@googlegroups.com> <51a0ca91$0$30002$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 26 May 2013 03:23:44 +1000 Subject: Re: help how to sort a list in order of 'n' in python without using inbuilt functions?? From: Chris Angelico To: python-list@python.org Content-Type: text/plain; charset=ISO-8859-1 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: 27 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1369502632 news.xs4all.nl 15883 [2001:888:2000:d::a6]:49151 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:46011 On Sun, May 26, 2013 at 3:17 AM, Carlos Nepomuceno wrote: > def f(x): > return x+1 > > or you can just go: > > f(roll_d6()) Hmm. Interesting. So now we have a question: Does adding 1 to a random number make it less random? It adds determinism to the number; can a number be more deterministic while still no less random? Ah! I know. The answer comes from common sense: a = random() # a is definitely a random number a -= random() # a is no longer random, we subtracted all the randomness from it Of course, since number-number => number, a is still a number. And so we can conclude that adding 1 to a random dice roll does indeed leave all the randomness still in it. But wait! That means we can do better!! a = random() # a is a random number a *= 5 # a is clearly five times as random now! ChrisA