Coders Packet

Rolling a Dice and Printing the Pattern of the Dice using Python

By Rupam Biswas

Here, we are rolling dice and printing the pattern of the dice in the terminal using python.

Step 1: First we are importing the 'random' module to choose a random value from the array and also importing the 'time' module for some delay.

Step 2: We are initializing different parts of the patterns to some variables.

Step 3: Taking an array with 6 different values (here 1 to 6).

Step 4: Choosing a random value from the array by using the 'random' module.

Step 5: Printing "Dice is rolling..." and giving 2-sec delay after that.

Step 6: Running an if-else condition to print different sides of the dice according to the value.

Here are every pattern of the dice:

1 = Dice 1,  2 =dice 2,  3 = dice 3,  4 = dice 4,  5 = dice 5,  6 = dice 6

Download Complete Code

Comments

No comments yet