How to create a random two point floating point number in python
3 answers
If you want to create a random number between two numbers, with a certain number of decimal places, here's a way:
import random greaterThan = float(1) lessThan = float(4) digits = int(2) rounded_number = round(random.uniform(greaterThan, lessThan), digits)
in this case your random number will be between 1 and 4, with two digits
+1
source to share