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 = , 2 =, 3 = , 4 = , 5 = , 6 =
Submitted by Rupam Biswas (Rupam)
Download packets of source code on Coders Packet