from random import *
def randfloat(x , y , maxfloatpt=None):
if x > y:
x , y = y , x
lenx = len(str(x))
leny = len(str(y))
intx = int(x)
inty = int(y)
bigger = max(lenx,leny)
if maxfloatpt == None:
if bigger == lenx:
intxlen = len(str(intx))
maxfloatpt = len(str(x)[intxlen:])
elif bigger == leny:
intylen = len(str(inty))
maxfloatpt = len(str(y)[intylen:])
else:
pass
else:
pass
num = randint(intx , inty)
num = str(num)
num = '%s.' % num
for i in range(0 , maxfloatpt):
flnum = randint(0 , 9)
str(flnum)
num = '%s%s' % (num , flnum)
return float(num)
P.S.: If the indent has anything wrong, just correct me, thx!
P.P.S.: The function is tested, it’s working 😊