Dice Rolling Stimulator Python Mini Project

We all know about dice. It’s a simple cube with numbers from 1 to 6 written on its face. But what is simulation? It is making a computer model. Thus, a dice rolling simulator is a simple computer model that can roll dice for us.

Build Dice Rolling Simulator

To Build Dice Rolling Simulator You need to follow the below steps

Step 1. Download Python

You only need Python to run this script. You can visit here to download Python.

Step 2. Write the following code

Write this code in a Python file or directly copy this code and save the file with the name and .py extension e.g python dice_stimulator.py

import random

print("This is a dice stimulator")
x = "y"
while x == "y":
number = random.randint(1,6)

if number == 1:
print("===========")
print("| |")
print("| O |")
print("| |")
print("===========")

if number == 2:
print("===========")
print("| |")
print("| O O |")
print("| |")
print("===========")

if number == 3:
print("===========")
print("| O |")
print("| O |")
print("| O |")
print("===========")

if number == 4:
print("===========")
print("| O O |")
print("| |")
print("| O O |")
print("===========")

if number == 5:
print("===========")
print("| O O |")
print("| O |")
print("| O O |")
print("===========")

if number == 6:
print("===========")
print("| O O |")
print("| O O |")
print("| O O |")
print("===========")

x = input("Press y to roll again ")

Step 3. Run the code

After saving the code double-click on the file to run the program or simply open Command Prompt and write following command

python dice_stimulator.py

Demo Dice Rolling Stimulator Python Mini Project:

ds

Leave a Comment