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]
- random.random() function in Python
- Python | Get unique values from a list
- Python | Get Unique values from list of dictionary
- Python | Get unique tuples from list
- Python | How to get unique elements in nested tuple
- Random sampling in numpy | random() function
- Python | Indices of sorted list of list elements
- How to get the unique elements of an array using NumPy?
- heapq in Python to print all elements in sorted order from row and column wise sorted matrix
- Python | Check if list contains all unique elements
- Python - List with most unique elements
- Generating Random Integers in Pandas Dataframe
- Python | Get random dictionary pair
- Python - Get Random Range Average
- How to get weighted random choice in Python?
- Python program to get all unique combinations of two Lists
- Python | Convert list of numerical string to list of Integers
- Python | Convert list of string into sorted list of integer
- Get unique values from a column in Pandas DataFrame
- Python | Generate random numbers within a given range and store in a 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 email@example.com. 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.