-3

Like the title suggests, this project involves writing a program that simulates rolling dice. When the program runs, it will randomly choose a number between 1 and 6. (Or whatever other integers you prefer — the number of sides on the die is up to you.) The program will print what that number is. It should then ask you if you’d like to roll again. Include tests for this program.

1 Answers1

-1

First, you will have to import a 'random' number using the 'random' number module. So the randint is a function which basically stands for Random Integer. THen you will define your functions and pass the range of numbers from which the random number will come from (0,6). So repeat=True basically helps you to play the game another more time while the .lower will convert the uppercase to the lower case in that one can choose to play the game while the caps lock is on or off.

#Dice Rolling Simulator
#dice.py

from random import randint

def rand():
    return randint(0,6)
    
repeat = True
while repeat:
    print("You rolled",rand())
    print("Do you want to roll again?")
    repeat = ("y" or "yes") in input().lower()
print("Game Over")