In python, I made this code to pick numbers from a list of numbers, excluding -1, 0 and 1. I can't find the equivalent in sage.
def alea(n, max):
complete_list = [i for i in range(-max, max+1, 1) if i != 0 and i != -1 and i != 1]
list = random.sample(complete_list, n)
return(list)
With Sage, I've done this :
sage: def alea(n, max):
....: list = [randrange(-max, max+1) for i in range(n)]
....: return list
....:
sage: a = alea(5,10)
sage: a
[1, 3, 8, -9, 7]
and as you can see, 1 is in the list of course.
My goal will then be to take for example 4 random numbers a, b, c and d, to make a sum of fractions a/b+c/d, and to generate the answer automatically to make a series of exercises in a document written with latex/sagetex. That's why I need to exclude -1, 0 and 1.
Thanks in advance for your help .