In: Computer Science
Python language:
Write a function dice(n) that returns a list
with the results of n dice rolls conducted with a six sided dice.
Use Numpy's random number functions to do this (Hint: use
randint() within numpy's random
module).
i.e. dice(3) returns something like [2,3,5] to indicate the first
dice obtained a 2, the second a 3 etc
Python 3
============================================================================================
import numpy as np
def dice(n):
l=np.random.randint(low=1,high=7,size=n)
return l
print(dice(3))
print(dice(7))
============================================================================================
Output