# To create a list of random integer values:
import random
randomlist = random.sample(range(10, 30), 5)
# Output:
# [16, 19, 13, 18, 15]
# To create a list of random float numbers:
import numpy
random_float_array = numpy.random.uniform(75.5, 125.5, 2)
# Output:
# [107.50697835, 123.84889979]
#To create a list of integer values that has random length with random values:
import random
#name of your list = (random.sample(range(of num the list elements has to be
#within),
#random.randint(range (of numbers your length of list may be))
list = (random.sample(range(1,10),random.randint(1,3)))
print(list)
#here list will have 3 elements and
#the elements will be witin 1 to 10
generate a list with random length and with random numbers python
import random
def main():
global random_int
random_int = random.randint(5, 13)
print random_int
makelist(random_int)
random_list.sort
string = ' ' . join([str(x) for x in random_list])
print string
def makelist(list_length):
global random_list
random_list = []
for x in range (list_length):
random_list.append(random.randint(0, 100))
main()