[Calc] Add random module functions
This commit is contained in:
parent
0c1901123e
commit
626b130186
16
calc.py
16
calc.py
@ -8,6 +8,7 @@ Copyright 2014, sfan5
|
||||
import ast
|
||||
import operator as op
|
||||
import math
|
||||
import random
|
||||
|
||||
# http://stackoverflow.com/questions/2371436/evaluating-a-mathematical-expression-in-a-string/9558001#9558001
|
||||
operators = {
|
||||
@ -19,11 +20,22 @@ funcs = {
|
||||
"bin": bin, "abs": abs, "oct": oct, "int": int, "sum": sum,
|
||||
"tuple": tuple, "divmod": divmod, "hash": hash, "hex": hex,
|
||||
"len": len, "list": list, "long": long, "max": max,
|
||||
"range": range, "round": round, "min": min
|
||||
"range": range, "round": round, "min": min,
|
||||
|
||||
# random functions
|
||||
"betavariate": random.betavariate, "choice": random.choice,
|
||||
"expovariate": random.expovariate, "gammavariate": random.gammavariate,
|
||||
"gauss": random.gauss, "getrandbits": random.getrandbits,
|
||||
"lognormvariate": random.lognormvariate, "normalvariate": random.normalvariate,
|
||||
"paretovariate": random.paretovariate, "randint": random.randint,
|
||||
"random": random.random, "randrange": random.randrange,
|
||||
"sample": random.sample, "shuffle": random.shuffle,
|
||||
"triangular": random.triangular, "uniform": random.uniform,
|
||||
"vonmisesvariate": random.vonmisesvariate, "weibullvariate": random.weibullvariate
|
||||
}
|
||||
|
||||
for funcn in dir(math):
|
||||
if funcn.startswith("__"):
|
||||
if funcn.startswith("_"):
|
||||
continue
|
||||
funcs[funcn] = getattr(math, funcn)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user