Generate Random Floating-Point Number in Range using Python

random.uniform function

import random


def generateRandomFloat(minValue, maxValue):
    return random.uniform(minValue, maxValue)


minValue = 10.5
maxValue = 20.5
randValue = generateRandomFloat(minValue, maxValue)

print(randValue)

Leave a Comment

Cancel reply

Your email address will not be published.