# Random dice roll program in Python

We will discuss one of the famous codes that is how to program Random dice roll in Python.

The program is popularly known as “Roll the dice”.

For this we will use the random module by taking randint() inbuilt function. randint() mainly deal with generating random numbers provided in the arguments that is minimum and maximum

## Random dice roll in Python

**Syntax:**

**random.randint(min,max)**

Min and Max should be Integer values. A random number will be automatically generated between 2 provided numbers. Here it is min and max.

Here we are setting the min as “**1**” and max as “**6**” because minimum number on the dice is 1 and maximum number on the dice is 6. The number on the dice are 1, 2, 3, 4, 5, 6. Hence we are setting the min and max as 1 and 6 respectively.

**Let’s see the Python code**

# import random module import random # Minimum and Maximum numbers on the dice are 1 and 6. min = 1 max = 6 # Setting the default value of flag to yes. Flag = "yes" while Flag == "yes" or Flag == "y": print("Now Rolling the dice...") print ("Number on the dice is: ") print(random.randint(min, max)) Flag = input("Are you interested to Roll the dice again? ")

Now below is given the output for our code:

Rolling the dice... Number on the dice: 4 Do you want to Roll the dice again? yes Rolling the dice... Number on the dice: 2 Do you want to roll the dice again? no

**Also read:**

## Leave a Reply