Python random module helps to generate random numbers.
We can generate this in three ways
randint(a, b) : returns a random integer number in the range [a, b]We can generate this in three ways
- randint(a, b)
- uniform(a, b)
- random()
uniform(a, b) : returns a floating point number in the range [a, b]
random() : returns a floating point number in the range [0, 1]
>>> import random
>>> a = random.randint(1,99)
>>> a
77
>>> b = random.uniform(1,999)
>>> b
766.6455229055509
>>> c = random.random()
>>> c
0.6372421095384033
>>>
Labels: python, random
0 comments: Post Yours! Read Comment Policy ▼
PLEASE NOTE:
We have Zero Tolerance to Spam. Chessy Comments and Comments with Links will be deleted immediately upon our review.