Coders Packet

Dice roll simulator using Python

By Noolu Samyuktha

In this module, The main goal is to create a program that will simulate the roll of dice.

Dice roll simulator using Python

This is a code snippet that includes the concept of a module called "random module". Random module functions depend on a pseudo-random number which is used to create random outputs. None of the output is decided it only picks a random from the set of outputs. And it eventually consists of looping and also an if-else statement.

Topics covered: 1. Random module 2. Looping 3. if-else

The main function of this code snippet is to generate a random number between the range from 1 to 6 when the user wants. This code snippet can directly be included in the programs that need dice to stimulate and produce a random number.

(Here is the code snippet to include)

 The code snippet to include

The program can perform 2 functions the first is to Roll the dice and the other is to Exit

Whenever the program is executed, it provides 2 options-

By, pressing

1: The Dice is rolled and a random output is produced between the range of 1 to 6 

2: The program terminates and exits from the console 

(Here is the output screenshot that displays the functions)

Output screenshot1

As described in the output screenshot Press 1 allows the program that consists of the random module to generate a random number on the dice.

(Here is the output that stimulates Dice)

Output screenshot 2

Every time, 1 is pressed a random number is generated, and 2 is pressed to Exit.

 

Download project

Reviews Report

Submitted by Noolu Samyuktha (samyukthanoolu)

Download packets of source code on Coders Packet