---------------------------------------- > 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: ros...@gmail.com > To: python-list@python.org > > On Sun, May 26, 2013 at 3:17 AM, Carlos Nepomuceno > <carlosnepomuc...@outlook.com> 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 > -- > http://mail.python.org/mailman/listinfo/python-list
It depends if the result (any operation) is in the required range. For example: "int(random.random()+1)" it's not random at all! But "int(random.random()*1000)" my look random if it fits your needs. ;) -- http://mail.python.org/mailman/listinfo/python-list