Math, asked by yadavdresses6813, 11 months ago

write a random number generator that generates random numbers between 1 and 6 (simulates a dice).

Answers

Answered by varun000
23

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.

Attachments:
Answered by ArunSivaPrakash
2

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

Similar questions