Python Random Function without using random module

后端 未结 6 1063
渐次进展
渐次进展 2021-02-09 17:14

I need to write the function -

random_number(minimum,maximum)

Without using the random module and I did this:

import time

def         


        
6条回答
  •  醉话见心
    2021-02-09 17:58


    finding random values between in a range(x,y)

    you need to subtract low range from high store at x

    then find random from 0-x

    then add the value to low range-> lowrange+x(x is random)


    import time
    def rand_val(x,y):
       sub=y-x
       random=int(time.time()*1000) 
       random %=sub
       random+=x
       return random
    x=int(input())
    y=int(input())
    print(rand_val(x,y))
    

提交回复
热议问题