range & random.sample functions
import random
def generateRandomNumbers(minValue, maxValue, qty):
numbers = range(minValue, maxValue + 1)
return random.sample(numbers, qty)
numbers = generateRandomNumbers(1, 10, 4)
print(numbers) # [1, 9, 5, 7]
Leave a Comment
Cancel reply