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 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 :: age calculator python 
Python :: login view django 
Python :: python find last index of character in string 
Python :: read bin file python 
Python :: python function to multiply two numbers 
Python :: palindrome python 
Python :: json.dump 
Python :: index in for loop 
Python :: class python example 
Python :: python remove last 4 characters from string 
Python :: if else usage python 
Python :: datetime am pm python 
Python :: Tree: Inorder Traversal 
Python :: python official documentation 
Python :: python ValueError: zero-size array to reduction operation maximum which has no identity 
Python :: python group by 
Python :: hide console in python build 
Python :: python run system commands 
Python :: getting url parameters with javascript 
Python :: rabbitmq python 
Python :: for en python 
Python :: pygame draw square 
Python :: Open the .txt file 
Python :: average of a list in function with python 
Python :: python how to add 2 numbers 
Python :: How to assign value to variable in Python 
Python :: armstrong number function 
Python :: excelwriter python 
Python :: pytube3 
Python :: pandas dataframe apply function with multiple arguments 
ADD CONTENT
Topic
Content
Source link
Name
7+5 =