help how to sort a list in order of 'n' in python without using inbuilt functions??
Chris Angelico
rosuav at gmail.com
Sat May 25 13:23:44 EDT 2013
On Sun, May 26, 2013 at 3:17 AM, Carlos Nepomuceno
<carlosnepomuceno at 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
More information about the Python-list
mailing list