Higher – Random Number Array Function

The class was asked to create a function that generated 100 number dice throws and stored them in an array.

This function is used to create an array of random integers. The size of the array and the magnatude of the values is set when the function is called.


def randomNumbers(size,min,max):
    # creates an array of (size) random numbers between min and max
    import random
    numbers=[]
    for loop in range(size):
        numbers.append(random.randint(min,max))
    return numbers

rndNumbers=randomNumbers(100,1,6)

Leave a Reply

Your email address will not be published. Required fields are marked *