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 11:41:58 EDT 2013


On Sun, May 26, 2013 at 12:28 AM, Steven D'Aprano
<steve+comp.lang.python at pearwood.info> wrote:
> On Sat, 25 May 2013 19:14:57 +1000, Chris Angelico wrote:
>
>> def random_number():
>>     return 7
>
> I call shenanigans! That value isn't generated randomly, you just made it
> up! I rolled a die *hundreds* of times and not once did it come up seven!

You've obviously never used a REAL set of dice. Now, I have here with
me a set used for maths drill (to be entirely accurate, what I have
here is the company's stock of them, so there are multiples of each of
these - anyone need to buy dice?) with everything except the classic 1
through 6 that everyone knows:

* Six sides, faces marked 7 through 12
* Six sides, faces marked "+x-\xf7+" and a "wild" marker (yes, two of +)
* Ten sides, numbered 0 through 9
* Eight sides, numbered 1 through 8
* Twelve sides, as above
* Twenty sides, as above

Now, tabletop roleplayers will recognize the latter four as the ones
notated as d10, d8, d12, and d20, but these are NOT for gameplay, they
are for serious educational purposes! Honest!

Anyway, all of those can roll a 7... well, one of them has to roll a
\xf7, but close enough right? Plus, if you roll 2d6 (that is, two
regular six-sided dice and add them up), 7 is statistically the most
likely number to come up with. Therefore it IS random.

ChrisA



More information about the Python-list mailing list