Skip to content

Instantly share code, notes, and snippets.

@kageru

kageru/pydie.py

Last active Jan 17, 2018
Embed
What would you like to do?
digital die, just paste in into the python/ipython shell
from random import randint
from functools import partial
def d(m, n=1):
s = 0
print(f'{n}d{m}')
for _ in range(n):
r = randint(1, m)
s += r
print(r)
if n > 1:
print('sum:', s)
d6 = partial(d, 6, 1)
d20 = partial(d, 20, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.