4hzub
4hzub

Reputation: 13

Python: Generate random floating point number in a range, excluding start-point

uniform(a,b) returns values in the range [a,b). How to turn this interval into (a,b)?

Upvotes: 1

Views: 459

Answers (1)

wim
wim

Reputation: 362557

This seems simple enough:

def my_uniform(a, b):
    while True:
        result = uniform(a, b)
        if a < result < b:
            return result

Upvotes: 2

Related Questions