Open Question - I'm a complete novice in programming so please bear with me...Is python equivalent to C, C++ and java combined?

Rotwang sg552 at hotmail.co.uk
Sun Jan 12 09:36:24 EST 2014


On 12/01/2014 05:58, Chris Angelico wrote:
> [...]
>
> (BTW, is there no better notation than six nested for/range for doing
> 6d6? I couldn't think of one off-hand, but it didn't really much
> matter anyway.)

If you're willing to do an import, then how about this:

 >>> from itertools import product
 >>> len([x for x in product(range(1, 7), repeat = 6) if sum(x) < 14])/6**6
0.03587962962962963



More information about the Python-list mailing list