Explore Courses Blog Tutorials Interview Questions
0 votes
1 view
in Python by (47.6k 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 (106k 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)


Related questions

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

28.4k questions

29.7k answers


94k users

Browse Categories