Python Random Function without using random module

后端 未结 6 1066
渐次进展
渐次进展 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

    Use API? if allowed.

    import urllib2
    
    def get_random(x,y):
        url = 'http://www.random.org/integers/?num=1&min=[min]&max=[max]&col=1&base=10&format=plain&rnd=new'
        url = url.replace("[min]", str(x))  
        url = url.replace("[max]", str(y))  
        response = urllib2.urlopen(url)
        num = response.read()
        return num.strip()
    
    print get_random(1,1000)
    

提交回复
热议问题