simple dice game using python - papa programmer

Simple Dice Game Using Python

In this tutorial we will make a simple dice game using python. So, let’s get started.

To make this game we need one module:

  • random

We need to use a random module to generate numbers between 1 to 6 each time. to get more info about the random module, you can check its documentation.

We start by importing the randint method or function from a random module. then we used while loop to continuously run our code (based on user input roll). we run our loop again and again when the input is “y”.

from random import randint

roll = "y"
while roll == "y":
    print("Rolling the dices...")
    dice1 = randint(1,6)
    dice2 = randint(1,6)
    print(dice1, dice2)

    roll = input("Roll Again?")
Simple Dice Game Using Python - papa programmer

This is the recent 3 outputs.

Related post: How to Make a Simple Calculator Using Python

Still wondering how to get started with python?

Check out our exclusive book,

How to Make a Simple Calculator Using Python - Papa Programmer
Leave a Reply

Your email address will not be published. Required fields are marked *

You May Also Like