Function in python -


i trying write linear congruential generator in python , find little piece of code on wikipedia have difficulty on understanding it. code follows:

def lcg(modulus, a, c, seed=none):     if seed != none:         lcg.previous = seed     random_number = (lcg.previous * + c) % modulus     lcg.previous = random_number     return random_number / modulus lcg.previous = 2222 

my problem "lcg.previous"? notice function done, value of lcg.previous gets updated , stored. declared member variable of function lcg() here or kind of default set function in python?

thanks lot!

it "member variable" of function, each time called (except when called seed) sequence pick of left off.


Comments