After we print the statements, we then write the input() after we write Press Enter to roll then the program rolls the dice and continues with the program else the dice will roll on its own the input() function tells it to roll after we press Enter. Then we roll the dice randomly to obtain the result and store it in a variable called number. we roll the dice with :

number = random.randint(1,6)

Step 2: Then we have to show what is the outcome of the dice roll. For that we have to write the if statement i.e. :

As we have stored the random number in the number variable between 1 and 6 , we can now check for each number that can be the possibility and then we can show that side of the Dice. From the above example we can create that for all the numbers from 1 to 6.

Step 3: Here we see that the dice rolls just once if we run the above program with the stated code. So, if we want to make it roll a few times then we have to write that the whole code in a while loop which if returns true will enter the block else will exit. So we select the whole code and then give the indentation then write the while loop a follows:

quit = 0while quit != “q”:

Here we define a variable quit and assign it to 0.Then we give the looping condition that if the value of quit is not equal to the character ‘q’ then continue the dice roll else not.

Step 4: Now we have to ask the user after each dice roll if he wants to quit, for that we write the code below the code in step 2 as the below example: