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

how to make a dice program in python

import random
run = 1
level = 0
while(run == 1):
        print("**ROUND " + str(level) + "**") 
        print("player 1: ",random.randint(0, 6))
        print("player 2: ",random.randint(0, 6))
        run = int(input("enter 1 to go again or 0 to end: "))
        print("")
        level += 1
Comment

how to make dice roll in python

#OM NAMAH SHIVA


import random
#computer picks a random number between 1 to 6
computer_choice = random.randint(1, 6)

print("you have 5 try's you scores more wins")
user_choice = int(input(["choose a number between 1 to 6"]))

#users_choice should not be higher than 6 
if user_choice >= 7:
    input("it should be between 1 to 6")
    #if user_choice input higher number than 7 two times it will quit the game
    if user_choice >= 7:
        exit()
#if user_choice is equal to computer_choice you win
if user_choice == computer_choice:
    print("you win")
    exit()

#if user_choice not equal to computer_choice you lose
else:
    print("you lose")
Comment

PREVIOUS NEXT
Code Example
Python :: python time function duration and memory usage 
Python :: python sftp put file 
Python :: load static files in django 
Python :: django expressionwrapper example 
Python :: pytorch save model 
Python :: check pip installed packages inside virtualenv 
Python :: python get all ips in a range 
Python :: printing a range of no one line in python 
Python :: django password change view 
Python :: how to get user input of list in python 
Python :: How can I get terminal output in python 
Python :: How to Create a Pie Chart in Seaborn 
Python :: A GDAL API version must be specified. Provide a path to gdal-config using a GDAL_CONFIG environment variable or use a GDAL_VERSION environment variable. 
Python :: getting image from path python 
Python :: how to change a string to small letter in python 
Python :: Geopandas to SHP file 
Python :: get_terminal_sizee python 
Python :: python dataframe get numeric columns 
Python :: scipy correlation 
Python :: gspread send dataframe to sheet 
Python :: tkinter gui grid and frame 
Python :: sns legend outside 
Python :: multiple input in python 
Python :: how to roll longitude coordinate 
Python :: python emoji 
Python :: pandas load dataframe without header 
Python :: converting datetime object format to datetime format python 
Python :: how to import subprocess in python 
Python :: count how many times a value shows in python list 
Python :: read csv exclude index pandas 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =