0

I am building a python module which will take the two numbers.Then it will find the random numbers between the two numbers for specific number of times and then add all of them a single variable. Then I will use the // operator to find the nearest and least whole number(integer in python). I have just made this much of code:

import random
def randint(minno, maxno, nooftime):

Here the minno is the least no and maxno is the maximum no and nooftime will be the no of times the random numbers will be generated and added to common variable(a , to be specific) then i will divide a by the nooftime by using this equation (a//nooftime) and then I will print the base quotient this module will be used for gaming purposes such as generating positions for an enemy to appear and for random map generaion

4

1 回答 1

1

这基本上重新实现了random.randint

from random import random

def randint(minno, maxno, nooftime):
    a = sum([random() * (maxno-minno) + minno for _ in range(nooftime)])
    return a // nooftime
于 2012-04-17T17:49:00.327 回答