Last active
September 28, 2019 01:52
-
-
Save Jadens-arc/9d53ac51061b21d9f55501a1668380be to your computer and use it in GitHub Desktop.
A dice simulator in python
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
import random, os | |
''' | |
run using python3 dice.py in terminal | |
made by Jaden Arceneaux | |
''' | |
dice = [] | |
total = 0 | |
def addDie(): | |
global total | |
print('how many sides does your die have') | |
dieSides = int(input()) | |
dice.append(dieSides) | |
def roll(): | |
global total, dice | |
for die in dice: | |
rolled = random.randint(0, die) | |
print('die numeber ' + str(dice.index(die) + 1) + ' rolled: ' + str(rolled)) | |
total += rolled | |
print('total: ' + str(total)) | |
total = 0 | |
dice = [] | |
while True: | |
for die in dice: | |
print(str(die) + ' sided die') | |
print('\nadd die\nroll\nquit') | |
userIn = input().lower() | |
if 'add die' in userIn: | |
addDie() | |
os.system('clear') | |
continue | |
elif 'roll' in userIn: | |
roll() | |
continue | |
elif 'quit' in userIn: | |
os.system('clear') | |
break | |
else: | |
print('not in system') | |
continue | |
print('bye \n -Jaden') | |
# ps I did it ismael |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment