Python Dice Roll Simulator Project

Python Dice Roll Simulator:

We can use the PyCharm code editor for this example. If you do not know about it then follow this link- How to install PyCharm for Python and create a program in it.

(1) Open the PyCharm code editor and create a new project in it. We named the project To build a Dice Roll Simulator in Python, we need to install some packages. For this open the terminal in PyCharm and install two packages i.e. tkinter and Pillow. You install all packages at the same time by simply typing in the terminal following command i.e. pip install tk Pillow and then press enter as shown below.

pip install tk pillow python

Note: If the package shows an error while using in the code, you can simply install the package by clicking on the red bulb which appears below the error and you can directly install the package from here.

(4) Now add some images in the path where you have created the project as shown below.

dice roll images for python

Download Images from Here: Dice Roll Project Images.

(3) Write the following code for creating Python Dice Roll Simulator Project as shown below.

Python Dice Roll Simulator Project Code 1
Python Dice Roll Simulator Project Code 2

Python Dice Roll Simulator Project Source Code:

import tkinter
from tkinter import *
from PIL import Image, ImageTk
import random

drs.title("Dice Roll Simulator")




def dice_roll():
    img1 = ImageTk.PhotoImage(

    img2 = ImageTk.PhotoImage(
    label2.image = img2

btn=tkinter.Button(drs,text="Dice Roll",bg="red",fg="white",font=("Merriweather",22,"bold"),command=dice_roll),y=0)


(4) Now run the code and a window pop up, click on the Dice Roll button to roll your dice. The output window will be shown below.

Python Dice Roll Simulator Project Output Window

Tutorial MySQL
Tutorial Python
Procedure-Oriented Programming
Modular Programming
Object-Oriented Programming (OOP)
C++ Character Set and Program Structure
FOR Loop in C Language
Python (programming language)– Wikipedia

Comments (No)

Leave a Reply