Skip to content

Instantly share code, notes, and snippets.

@rudrathegreat
Forked from davidlivingrooms/test.py
Last active January 1, 2019 13:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rudrathegreat/8ca789e9d4b3de145d699fece6eacfff to your computer and use it in GitHub Desktop.
Save rudrathegreat/8ca789e9d4b3de145d699fece6eacfff to your computer and use it in GitHub Desktop.
Dice Program for Python 3
'''
This program is designed for the original Python 3
and not for Python 2. Check out the original program
which is designed for Python 2.
Also check out my dice program fr the BBC MicroBit
here -
https://gist.github.com/rudrathegreat/f42e1ca01c81ea9973e4653b60c16085
https://gist.github.com/rudrathegreat/ed7db24af713ae8d42444bc0816d19c6
'''
import random
from time import sleep
class Dice(object):
def __init__(self, min, max):
pass
self.min = min
self.max = max
self.roll = False
def roll_dice(self, input = ''):
while self.roll == False:
response = input('>')
if response == 'r':
self.roll = True
break
if input == 'double':
num1 = random.randint(self.min, self.max)
num2 = random.randint(self.min, self.max)
return num1, num2
if input == 'single':
num = random.randint(self.min, self.max)
return num
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment