-
-
Save rudrathegreat/8ca789e9d4b3de145d699fece6eacfff to your computer and use it in GitHub Desktop.
Dice Program for Python 3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
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