Processing math: 100%

First time here? Check out the FAQ!

Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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
click to hide/show revision 2
No.2 Revision

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.

click to hide/show revision 3
No.3 Revision

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.