Given lower and upper limits, generate a sorted list of random numbers with unique elements, starting from start to end.
Input: num = 10, start = 100, end = 200 Output: [102, 118, 124, 131, 140, 148, 161, 166, 176, 180] Input: num = 5, start = 1, end = 100 Output: [37, 49, 64, 84, 95]
To generate random numbers in Python,
randint() function of
random module is used.
randint() accepts two parameters: a starting point and an ending point. Both should be integers and the first value should always be less than the second.
Below is the implementation.
[102, 118, 124, 131, 140, 148, 161, 166, 176, 180] [37, 49, 64, 84, 95]
- Python | Check if list contains all unique elements
- Python | Indices of sorted list of list elements
- heapq in Python to print all elements in sorted order from row and column wise sorted matrix
- Python | Convert list of numerical string to list of Integers
- Python | Select random value from a list
- Program to print N minimum elements from list of integers
- Python | Remove random element from list
- Generating random number list in Python
- Python | Get unique values from a list
- Python | Get unique tuples from list
- Python | Assign ids to each unique value in a list
- Python | Unique pairs in list
- Python - Summation of Unique elements
- Python | Count unique sublists within list
- Python | Assign value to unique number in list
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.