Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

dice simulator in python

import speech_recognition as sr
import pyttsx3
import random

engine = pyttsx3.init('sapi5')
voices = engine.getProperty('voices')
# print(voices[1].id)
engine.setProperty('voice', voices[0].id)


def speak(audio):
    engine.say(audio)
    engine.runAndWait()

no = random.randint(1,6)
print(no)

if no == 1:
        print("[-----]")
        print("[     ]")
        print("[  0  ]")
        print("[     ]")
        print("[-----]")
if no == 2:
        print("[-----]")
        print("[ 0   ]")
        print("[     ]")
        print("[   0 ]")
        print("[-----]")
if no == 3:
        print("[-----]")
        print("[     ]")
        print("[0 0 0]")
        print("[     ]")
        print("[-----]")
if no == 4:
        print("[-----]")
        print("[0   0]")
        print("[     ]")
        print("[0   0]")
        print("[-----]")
if no == 5:
        print("[-----]")
        print("[0   0]")
        print("[  0  ]")
        print("[0   0]")
        print("[-----]")
if no == 6:
        print("[-----]")
        print("[0 0 0]")
        print("[     ]")
        print("[0 0 0]")
        print("[-----]")
          
speak(f"your number is: {no}")
Comment

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)
Comment

dice rolling simulator python

from random import randint

def roll_dice():
    print(f"Number is: {randint(1,6)}")

# Do this to simulate once
roll_dice()   

# Do this to simulate multiple times
whatever = 12 # Put the number of times you want to simulate here
for number in range(whatever):
    roll_dice()
Comment

dice rolling simulator python code

import random
 
 
x = "y"
  
while x == "y":
     
    # Generates a random number
    # between 1 and 6 (including
    # both 1 and 6)
    no = random.randint(1,6)
     
    if no == 1:
        print("[-----]")
        print("[     ]")
        print("[  0  ]")
        print("[     ]")
        print("[-----]")
    if no == 2:
        print("[-----]")
        print("[ 0   ]")
        print("[     ]")
        print("[   0 ]")
        print("[-----]")
    if no == 3:
        print("[-----]")
        print("[     ]")
        print("[0 0 0]")
        print("[     ]")
        print("[-----]")
    if no == 4:
        print("[-----]")
        print("[0   0]")
        print("[     ]")
        print("[0   0]")
        print("[-----]")
    if no == 5:
        print("[-----]")
        print("[0   0]")
        print("[  0  ]")
        print("[0   0]")
        print("[-----]")
    if no == 6:
        print("[-----]")
        print("[0 0 0]")
        print("[     ]")
        print("[0 0 0]")
        print("[-----]")
         
    x=input("press y to roll again and n to exit:")
    print("
")
Comment

PREVIOUS NEXT
Code Example
Python :: python mysqldb 
Python :: how to extract numbers from a list in python 
Python :: how to keep a webdriver tab open 
Python :: np.hstack 
Python :: im save to a bytes io python 
Python :: maping value to data in pandas dataframe 
Python :: load and image and predict tensorflow 
Python :: converting month number to month name python 
Python :: length of a matrix in python 
Python :: make sure text is on page selenium python 
Python :: install from github 
Python :: python multithreading tutorials 
Python :: how to create obtain any random 3 items of list in python 
Python :: python pil to greyscale 
Python :: write text in list to text file python 
Python :: change selected option optionmenu tkinter 
Python :: read csv without header pandas 
Python :: dataframe change column value 
Python :: get title attribute beautiful soup 
Python :: python set remove 
Python :: how to commenbt code in python 
Python :: how to add color to python text 
Python :: apostrophe in python 
Python :: django form set min and max value 
Python :: python pad with zeros 
Python :: check python version kali linux 
Python :: python file handling 
Python :: button size tkinter 
Python :: python size of linked list 
Python :: python bold text in terminal 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =