Dice Rolling Simulator using Python-random Last Updated : 13 May, 2022 Comments Improve Suggest changes Like Article Like Report In this article, we will create a classic rolling dice simulator with the help of basic Python knowledge. Here we will be using the random module since we randomize the dice simulator for random outputs. Function used: 1) random.randint(): This function generates a random number in the given range. Below is the implementation. Example 1: Dice Simulator Python3 import random x = "y" while x == "y": # Generates a random number # between 1 and 6 (including # both 1 and 6) no = random.randint(1,6) if no == 1: print("[-----]") print("[ ]") print("[ 0 ]") print("[ ]") print("[-----]") if no == 2: print("[-----]") print("[ 0 ]") print("[ ]") print("[ 0 ]") print("[-----]") if no == 3: print("[-----]") print("[ ]") print("[0 0 0]") print("[ ]") print("[-----]") if no == 4: print("[-----]") print("[0 0]") print("[ ]") print("[0 0]") print("[-----]") if no == 5: print("[-----]") print("[0 0]") print("[ 0 ]") print("[0 0]") print("[-----]") if no == 6: print("[-----]") print("[0 0 0]") print("[ ]") print("[0 0 0]") print("[-----]") x=input("press y to roll again and n to exit:") print("\n") Output:Â Example 2: Dice simulator Python import random while True: print('''1.roll the dice 2.To exit ''') user = int(input("what you want to do\n")) if user==1: number = random.randint(1,6) print(number) else: break Output: Â Â Comment More infoAdvertise with us Next Article Dice Rolling Simulator using Python-random S shivalibhadaniya Follow Improve Article Tags : Python Python-random Practice Tags : python Similar Reads GUI Dice Roll Simulation using Python In this article, we are going to create Rolling The Dices Game using Tkinter and a random module in Python. A random module in Python is a built-in module used to generate random numbers for various distributions. Here, we will use this module to create random outcomes for our dice. Python offers va 4 min read Automatic Tic Tac Toe Game using Random Number - Python Tic-Tac-Toe is a simple and fun game. In this article, weâll build an automatic version using Python. The twist is that the game plays itself, no user input needed! Players randomly place their marks on the board and the winner is declared when three in a row is achieved.Weâll use:NumPy for managing 3 min read random.setstate() in Python Random module is used to generate random numbers in Python. Not actually random, rather this is used to generate pseudo-random numbers. That implies that these randomly generated numbers can be determined. random.setstate() The setstate() method of the random module is used in conjugation with the g 2 min read randrange() in Python The randrange() function in Python's random module is used to generate a random number within a specified range. It allows defining a start, stop, and an optional step value to control the selection of numbers. Unlike randint(), which includes the upper limit, randrange() excludes the stop value. Ex 4 min read Python Random - random() Function There are certain situations that involve games or simulations which work on a non-deterministic approach. In these types of situations, random numbers are extensively used in the following applications: Creating pseudo-random numbers on Lottery scratch cardsreCAPTCHA on login forms uses a random nu 3 min read Like