write a random number generator that generates random numbers between 1 and 6 (simulates a dice).
Answers
I have written the code for this program along with the output... hope you get it dear....
Mark it as brainliest if you find it helpful.
The code for a random number generator that generates random numbers between 1 and 6 (simulates a dice) is given below.
Given:
The random numbers to be generated = 1, 2, 3, 4, 5, 6.
To Find:
We have to write a random number generator that generates random numbers between 1 and 6 (simulates a dice).
Solution:
import random
def rolladice ():
counter = 0
myList = [ ]
while (counter) < 6 :
randomNumber = random.randint (1,6)
myList.append (randomNumber)
counter = counter + 1
if counter >=6 :
pass
else:
return myList
# Take user input here
n=1
while (n==1) :
n = int (input ("Enter 1 to roll a dice and get a random number:") )
print (rolladice() )
Hence, the code for a random number generator that generates random numbers between 1 and 6 (simulates a dice) is obtained.
#SPJ3