If you take any application, big or small, generating a random number is one of the basic operations required.

If you are a big fan of writing unit test cases, you must have implemented this for mock data generation.

We can utilize the random module in python to generate a random number in python. List of methods offered by the random module to generate the number.

1. random()
2. randint()
3. sample()

## Generate a Random Number using the random function in python

The random() function takes no parameters and returns values uniformly distributed between 0 and 1.

```import random
randomNumber=random.random()
print(randomNumber)```

## Random Function With Range in Python

We can use random.rand function to generate the random number between the lower and higher value provided in the function.

```import random
randomNumber=random.randint(10,55)
print(randomNumber)```

As you can see in the above program, numbers will be generated between only 10 and 44.

## Random Sample Function in Python

To instantly generate a list of random numbers, we can also use the sample() method offered by the random module. Here, we specify a range and the number of random numbers that should be generated.

```import random
randomlist = random.sample(range(10, 30), 5)
print(randomlist)
```

## Conclusion

random module provides a list of methods that can be used to generate the random number. we have explored a few of the random, randint , and sample methods in it.  