Got it! This site uses cookies. You consent to this by clicking on "Got it!" or by continuing to use this website.nbsp; Note: This appears on each machine/browser from which this site is accessed.
Python has the ability to create random class instances, each a separate RNG (Random Number Generator)
This allows multiple independent random number generators to be created and used that do not share state.
This is done with the random.Random class.
2. Usefulness
This can be useful for certain simulations whereby certain types of repeatable randomness is needed in the presence of parts of a program that change.
3. Python program
Here is the Python code.
Here is the output of the Python code.
The random numbers for the lower-left (2, 1) cell and the upper-right (1, 2) cell are different for the shared RNG but the same when using and independent RNG for each cell.
4. Table structure
One way to represent a 2D table structure is as follows, using lists of lists.