Python comes with a built-in random library. It has got lots of functions included with this library such as choice, randint etc.
For generating a random number in python firstly we have to import a module random.
import random a=random.random() print(a)
In this random module we can use many functions.
- randint()- It generates the number in a given range.
import random a=random.randint(0,100) print(a)
- rand()- It generates the float number.
from numpy import random x=random.rand(5) print(x)