Ask Your Question

Revision history [back]

Sage language is Python with some additional functions and classes.

So, Sage has a random function defined, that returns a random number in the interval $[0,1]$:

sage: random()
0.2808809147593442

If you want to use the sample function from the random python module, you just have tom import it before your Python code:

sage: import random

Sage language is Python with some additional functions and classes.

So, Sage has a random function defined, that returns a random number in the interval $[0,1]$:

sage: random()
0.2808809147593442

If you want to use the sample function from the random python module, you just have tom import it before your Python code:

sage: import random

If you do not want to overwrite the random Python function, you can do:

sage: from random import sample

but then use sample instead of random.sample.

Sage language is Python with some additional functions and classes.

So, Sage has a random function defined, that returns a random number in the interval $[0,1]$:

sage: random()
0.2808809147593442

If you want to use the sample function from the random python module, you just have tom import it before your Python code:

sage: import random

If you do not want to overwrite the random Sage function by the random Python function, module, you can do:

sage: from random import sample

but then use sample instead of random.sample.