On Sun, 26 May 2013 01:41:58 +1000, Chris Angelico wrote: > On Sun, May 26, 2013 at 12:28 AM, Steven D'Aprano > <steve+comp.lang.pyt...@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.
You're right, all my dice are eight-sided and complex: 1+0i 1+1i 1-1i -1+0i -1+1i -1-1i :-) But seriously, I have various D&D style gaming dice, d4, d6, d8, d12, d20 and d30. But I thought the opportunity for a joke was more important than pedantic correctness :-) > 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?) Are you serious? What's the cost, posted to Melbourne? > 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 +) Oh, you mean ÷ (division sign)! Why didn't you say so? :-P And another thing, shame on you, you mean × not x. It's easy to find too: py> from unicodedata import lookup py> print(lookup("MULTIPLICATION SIGN")) × > * 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? I don't think so... > 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. Yes, but if you subtract them the most common is 0, if you multiply the most common are 6 or 12, and if you divide the most common is 1. If you decide on the operation randomly, using the +-×÷+ die above (ignoring wildcards), the most common result is 6. The probability of getting a 7 is just 1/15. from collections import Counter from operator import add, sub, mul, truediv as div ops = (add, sub, mul, div, add) Counter(op(i, j) for op in ops for i in range(1, 7) for j in range(1, 7)) -- Steven -- http://mail.python.org/mailman/listinfo/python-list