Ask Your Question

Revision history [back]

You can look at the documentation of N with:

sage: N?

You can see that, besides the prec option, there is a digit option that does the job:

sage: print(N(pi, digits=4))
3.142
sage: print(N(pi, digits=6))
3.14159
sage: print(N(pi, digits=12))
3.14159265359