Generating Random Numbers

Write a Python program that uses the random module to generate a list of 10 random numbers between 0 and 50. Return the list of numbers.


This will depend on the random numbers generated.


The random module in Python has a function randint() which generates a random number within the provided range. You can use a list comprehension to generate 10 random numbers.

import random

def generate_random_numbers():
    return [random.randint(0, 50) for _ in range(10)]


© Let’s Data Science


Unlock AI & Data Science treasures. Log in!