Ask Your Question

Revision history [back]

Note that your script is not pure Python since it relies on the Sage preparser (e.g. you use ^ for power while in Python it should be **).

You can put this into a file with a .sage extension, for example myscript.sage so that Sage will understand that the script has to be preparsed, then you can call the script either from the terminal with

./sage myscript.sage

or from the Sage console with:

 %runfile myscript.sage