Ask Your Question

Revision history [back]

The underscore _ stores the previous result (double underscore __ stores the pre-previous and triple underscore ___ stores the pre-pre-previous):

sage: 10 * 10
100
sage: _ + 1
101
sage: __ + 3
103
sage: ___ + 5
105

The underscore _ stores the previous result (double result. The double underscore __ stores the pre-previous and triple underscore ___ stores the pre-pre-previous):pre-pre-previous:

sage: 10 * 10
100
sage: _ + 1
101
sage: __ + 3
103
sage: ___ + 5
105

You may also use the list Out which stores all of the results:

sage: Out
{1: 100, 2: 101, 3: 103, 4: 105}

The SageMath command line and Jupyter notebook are both based on ipython. As described in the section Output caching system documention ipython, the underscore _ stores the previous result. The double underscore __ stores the pre-previous and triple underscore ___ stores the pre-pre-previous:

sage: 10 * 10
100
sage: _ + 1
101
sage: __ + 3
103
sage: ___ + 5
105

You may also use the list Out which stores all of the results:

sage: Out
{1: 100, 2: 101, 3: 103, 4: 105}

or _<n> where n the n-th output from the start:

sage: _3
103

SageMath command line and Jupyter notebook are both based on ipython. As described in the section Output caching system of the documention of ipython, the underscore _ stores the previous result. The double underscore __ stores the pre-previous and triple underscore ___ stores the pre-pre-previous:

sage: 10 * 10
100
sage: _ + 1
101
sage: __ + 3
103
sage: ___ + 5
105

You may also use the list Out which stores all of the results:

sage: Out
{1: 100, 2: 101, 3: 103, 4: 105}

or _<n> where n the n-th output from the start:

sage: _3
103