how to make a dice in python

Solutions on MaxInterview for how to make a dice in python by the best coders in the world

showing results for - "how to make a dice in python"
Jasmine
06 Jan 2021
1from random import randint
2
3def roll_dice():
4    print(f"Number is: {randint(1,6)}")
5
6# Do this to simulate once
7roll_dice()   
8
9# Do this to simulate multiple times
10whatever = 12 # Put the number of times you want to simulate here
11for number in range(whatever):
12    roll_dice()
Malia
17 Aug 2018
1#For one time roll
2from random import randint
3
4dice_roll = randint(1,6) 
5#You can change numbers to anything you want, it can go up to 1 million if you really want it to
6print("You Threw a", dice_roll)
7#That's for one time throw but if you want it for multiple people then do this
8
9#For multiple roles 
10import time
11from random import randint
12for j in range(10):
13    dice_roll = randint(1,6)
14    time.sleep(3)
15    print("You threw a", dice_roll)
16
17