Share
Can you create a large list with random numbers?
Question
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Create a list of 1000 random numbers
Answer ( 1 )
#creating a large list in python using random numbers
#assuming random numbers to fall between 1 to 100 and integers
import random #library to generate random numbers
randlist = [] #creating an empty list
for i in range(0, 1000): #for loop for generating random numbers and appending the list
n = random.randint(1, 100)
randlist.append(n)
print(“the list generated with random numbers is n”, randlist)