0 votes
1 view
in Python by (47.8k points)

randrange(start, stop) only takes integer arguments. So how would I get a random number between two float values?

1 Answer

0 votes
by (107k points)

If you want to get a random number between a float range then you can use random.uniform(a,b), this function will return a random floating point number N where the range of N would be; a <= N <= b for a <= b and b <= N <= a for b < a.

import random

random.uniform(1.2, 1.5)

image

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...