In: Computer Science
To create a list with random numbers we use the module named random.
Code:
import random
my_list=random.sample(range(100),40)
It creates a list my_list with 40 random
integers in range 1 to 100.
Above screenshot shows the output of the code which has 40 random integers.
CODE:
Every line of the code is explained in the above pic
Above screenshot contains the code that creates the function of name lists to create two lists even,odd that contains even elements and odd elements from the list my_list created from numbers and two variables a,b to find the length of two lists..
Every time you run the above code it creates a lists with random integers.
OUTPUT1:
OUTPUT2:
ANY QUERIES REGARDING THE SOLUTION PLEASE COMMENT.