| 1 | initial version |
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.)
| 2 | No.2 Revision |
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.)
Copyright Sage, 2010. Some rights reserved under creative commons license. Content on this site is licensed under a Creative Commons Attribution Share Alike 3.0 license.