Here is my solution. First, I create random numbers with random.uniform, format them into a double precision string, and then convert them back to float. You can adjust the accuracy by changing ".2f" to ".3f", etc.
import random from decimal import Decimal GndSpeedHigh = float(format(Decimal(random.uniform(5, 25)), '.2f')) GndSpeedLow = float(format(Decimal(random.uniform(2, GndSpeedHigh)), '.2f')) GndSpeedMean = float(Decimal(format(GndSpeedHigh + GndSpeedLow) / 2, '.2f'))) print(GndSpeedMean)
Bittikettu Mar 31 '15 at 11:31 2015-03-31 11:31
source share