13. Write a python program randomly generate a list of eight odd numbers in the range of 1 to 50.
The output is:
Expected Answer:
[17, 21, 23, 45, 27, 35, 41, 31]
Sample Answer:
import random print(random.sample([i for i in range(1,50) if i%2!=0], 8))
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)