xxxxxxxxxx
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}")
xxxxxxxxxx
# high depends on what type of dice you are playing with
# size depends on how many dice you want to play with
# If you consider playing with 10 coins as dices, then high = 2 (1 coin has 2 sides) and no_of_dice = 10
# If you consider playing with 5 ludo dices, then high = 6 (1 dice has 6 sides) and no_of_dice = 5
# replace=True for any previous occurrence is likely to occur again
import numpy as np
simulation = np.random.choice(list(range(1,high+1)), size=no_of_dice, replace=True)
xxxxxxxxxx
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()
xxxxxxxxxx
#dice roller ascii art
import random
input("Welcome to Ascii Dice roller\n")
dice_6 = " _____ \n|X X X|\n| |\n|X X X|\n ----- \n "
dice_4 = " _____ \n|X X|\n| |\n|X X|\n ----- \n "
dice_5 = " _____ \n|X X|\n| X |\n|X X|\n ----- \n "
dice_1 = " _____ \n| |\n| X |\n| |\n ----- \n "
dice_2 = " _____ \n| X |\n| |\n| X |\n ----- \n "
dice_3 = " _____ \n| X |\n| X |\n| X |\n ----- \n "
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}\n"))
if(person_input > 0 and person_input < 6):
break
else:
print("Too Many\n")
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)
xxxxxxxxxx
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("\n")