Random Numbers:

In Python, we have a set of functions that are there to generate or manipulate random numbers. These functions in Python are helpful in a lot of things. Such as games, lotteries or places where random number generation is there. It has high usage in the field of Data Science with python as well.

Operations on Random Numbers:

  1. choice() – This function comes in handy to generate 1 random number from a container.
  2. Randrange(beg, end, step) – As we call this function, it generates a random number but within a specific range we provide in its argument. The function takes three arguments, the beginning number(this is inclusive of generation). The last number (this is not inclusive of generation) and step( this skips numbers in range during selection).

random in python for data science

  1. random() – This function is there for generating a float random number which is less than 1 but also greater than or equal to 0.
  2. seed() – This is a function which maps a particular random number with seed arguments which are there. All the random numbers which we call after the seeded value returns the mapped number.python data science
  3. shuffle() – When we use this function, it shuffles the entire list to arrange them randomly.
  4. Uniform(a, b) – This is a function that is there for generating a floating point random number between numbers which are mention in the argument. This function takes two arguments. And lower limit which is generated in generation and upper limit, which is not limited in generation.

If you want to learn more about random function in python for data science then you can check this and this as well.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.