Operations with Randon's numbers:
1. choice () : — This function is used to generate 1 random number from a container.
2. randrange (beg, end, step) : — This function is also used to generate a random number, but within the range specified in its arguments. This function takes 3 arguments: start number (included in generation), last number (excluded during generation) and step (to skip numbers in the range when selected).
A random number from list is: 4 A random number from range is: 41
3. random () : — This number is used to generate a random number with a floating point less than 1 and greater than or equal to 0.
4. seed () : — This function displays a specific random number with the specified seed . All random numbers called after the seeded value will return the matched number.
A random number between 0 and 1 is: 0.510721762520941 The mapped random number with 5 is: 0.6229016948897019 The mapped random number with 7 is: 0.32383276483316237 The mapped random number with 5 is: 0.6229016948897019 The mapped random number with 7 is: 0.32383276483316237
5. shuffle () : — this function is used to shuffle the entire list, to randomly arrange them.
6.iform (a, b) : — this function is used to generate a random number with a floating point between the numbers given in its arguments. It takes two arguments: a lower limit (included in generation) and an upper limit (not included in generation).
The list before shuffling is: 1 4 5 10 2 The list after shuffling is: 2 1 4 5 10 The random floating point number between 5 and 10 is: 5.183697823553464
This article is provided by Manjit Singh. If you are as Python.Engineering and would like to contribute, you can also write an article using contribute.python.engineering or by posting an article contribute @ python.engineering. See my article appearing on the Python.Engineering homepage and help other geeks.
Please post comments if you find anything wrong or if you would like to share more information on the topic discussed above.