Ask Your Question

Revision history [back]

The issue is that Python integers are not the same as Sage integers: Sage integers have more functionality. The command random.randint(...) returns a Python integer, so you need to convert it to a Sage integer, for example with {{{ b[r]=Integer(random.randint(0,3^15-1)) }}} I would also recommend changing the last line to {{{ print(q) }}} The syntax print q will stop working with recent releases of Sage. (print with no parentheses is valid Python 2 syntax but not valid Python 3 syntax, and as of version 9.0, Sage is based on Python 3.)

The issue is that Python integers are not the same as Sage integers: Sage integers have more functionality. The command random.randint(...) returns a Python integer, so you need to convert it to a Sage integer, for example with {{{ with

b[r]=Integer(random.randint(0,3^15-1))
}}}

I would also recommend changing the last line to {{{ to

print(q)
}}}

The syntax print q will stop working with recent releases of Sage. (print with no parentheses is valid Python 2 syntax but not valid Python 3 syntax, and as of version 9.0, Sage is based on Python 3.)