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 Roller in Python

#importing module for random number generation
import random

#range of the values of a dice
min_val = 1
max_val = 6

#to loop the rolling through user input
roll_again = "yes"

#loop
while roll_again == "yes" or roll_again == "y":
    print("Rolling The Dices...")
    print("The Values are :")
    
    #generating and printing 1st random integer from 1 to 6
    print(random.randint(min_val, max_val))
    
    #generating and printing 2nd random integer from 1 to 6
    print(random.randint(min_val, max_val))
    
    #asking user to roll the dice again. Any input other than yes or y will terminate the loop
    roll_again = input("Roll the Dices Again?")
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 :: dns request scapy 
Python :: infinity in python 
Python :: python current date and time 
Python :: copy files python 
Python :: how to get input in tkinter 
Python :: how to create dynamic variable names in python 
Python :: python get ip from hostname 
Python :: np euclidean distance python 
Python :: how to append to text file with new line by line in python 
Python :: pandas left join 
Python :: pandas determine percentage of nans in column 
Python :: web3py convert from wei to ether 
Python :: python convert current datetime to rfc 1123 format 
Python :: how to add static files in django 
Python :: blender python set object location 
Python :: make length string in pandas 
Python :: np.save function 
Python :: string to time python 
Python :: remove comma from string python column 
Python :: cors error in flask 
Python :: learn python the hard way pdf 
Python :: standardize columns in pandas 
Python :: openpyxl font 
Python :: conda install nltk 
Python :: how to install flask 
Python :: version of scikit learn 
Python :: load saved model 
Python :: get python version in code 
Python :: python count repeated elements in a list 
Python :: python send sms 
ADD CONTENT
Topic
Content
Source link
Name
4+9 =