Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

dice roller python

#dice roller ascii art
import random

input("Welcome to Ascii Dice roller
")

dice_6 = " _____ 
|X X X|
|     |
|X X X|
 ----- 
   "
dice_4 = " _____ 
|X   X|
|     |
|X   X|
 ----- 
   "
dice_5 = " _____ 
|X   X|
|  X  |
|X   X|
 ----- 
   "
dice_1 = " _____ 
|     |
|  X  |
|     |
 ----- 
   "
dice_2 = " _____ 
|   X |
|     |
| X   |
 ----- 
   "
dice_3 = " _____ 
|   X |
|  X  |
| X   |
 ----- 
   "

Dice = [dice_1,dice_2,dice_3,dice_4,dice_5,dice_6]

# makes greet cool
rolls = random.choice(Dice)
print(rolls)

# whle loop from dice roller
while True:
    try:
        person_input = int(input("How many dice would you like to roll?...{1-5}
"))
        if(person_input > 0 and person_input < 6):
            break
        else:
        print("Too Many
")
    except:
        print("Woah Woah type a number")

#define rolls and formating the output
def dice_rolls(dice_amount):

    for dice in range(dice_amount):
        rolls =random.choice(Dice)
        print(rolls)
#      prints^the # of rolls
dice_rolls(person_input)
 
PREVIOUS NEXT
Tagged: #dice #roller #python
ADD COMMENT
Topic
Name
2+1 =