Python Mini Projects – Dice Roll Simulator

In this we will create Dice Roll Simulator

JUST TRY ON YOUR OWN

import random 
while True:     
     print(''' 1. roll the dice             2. exit     ''')    
     user = int(input("what you want to do\n"))     
     if user==1:         
        number = random.randint(1,6)         
        print(number)     
     else:         
        break

Second Code for Dice Roll Simulator

import random
#When you run the program you'll get a random number between 1-6
roll_again="yes"
#if you want to roll again you can give the input accordingly
while(roll_again=="yes" or roll_again=="y"):
    #random.randint() function will give you a random integer from the specified range
    print(random.randint(1,7))
    roll_again=input("Do you want to roll again: y/yes or n/no:: ")

Leave a Comment