ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Tue, 20 Aug 2019 02:39:28 -0500Perform arithmetic on previous answer/result, without copying/re-entering it?http://ask.sagemath.org/question/10295/perform-arithmetic-on-previous-answerresult-without-copyingre-entering-it/I enter the following in sage:
<code>361-4*-216 #sage comment: I would like sqrt this without copying & pasting<code>
I'd like to then obtain the sqrt of that answer after its been generated.
On the Ti-83 plus, the device was able to generate 'Ans' after I pressed an arithmetic symbol such as division.Sat, 29 Jun 2013 12:32:56 -0500http://ask.sagemath.org/question/10295/perform-arithmetic-on-previous-answerresult-without-copyingre-entering-it/Answer by ASDqwelk for <p>I enter the following in sage:</p>
<p><code>361-4*-216 #sage comment: I would like sqrt this without copying & pasting<code></code></code></p><code><code>
<p>I'd like to then obtain the sqrt of that answer after its been generated.</p>
<p>On the Ti-83 plus, the device was able to generate 'Ans' after I pressed an arithmetic symbol such as division.</p>
</code></code> http://ask.sagemath.org/question/10295/perform-arithmetic-on-previous-answerresult-without-copyingre-entering-it/?answer=47519#post-id-47519在宝宝断奶的时候不要一下子停止，要循序渐进地慢慢来<a href="http://fngzweb.com" title="丰胸产品">丰胸产品</a>，可以母乳和人工喂养相结合，组成一个过渡阶段。在晚上或者是其他睡觉的时候<a href="https://1807614030.wixsite.com/fngz" title="粉嫩公主">粉嫩公主</a>，平躺下，把胸罩解开。每天都要给乳房进行按摩<a href="https://1807614030.wixsite.com/fngzgw" title="产后丰胸产品">产后丰胸产品</a>，用温水清洗，这样可以促进乳房的血液循环<a href="https://1807614030.wixsite.com/fngzjnd" title="丰胸方法">丰胸方法</a>。
Tue, 20 Aug 2019 02:39:28 -0500http://ask.sagemath.org/question/10295/perform-arithmetic-on-previous-answerresult-without-copyingre-entering-it/?answer=47519#post-id-47519Answer by dazedANDconfused for <p>I enter the following in sage:</p>
<p><code>361-4*-216 #sage comment: I would like sqrt this without copying & pasting<code></code></code></p><code><code>
<p>I'd like to then obtain the sqrt of that answer after its been generated.</p>
<p>On the Ti-83 plus, the device was able to generate 'Ans' after I pressed an arithmetic symbol such as division.</p>
</code></code> http://ask.sagemath.org/question/10295/perform-arithmetic-on-previous-answerresult-without-copyingre-entering-it/?answer=15160#post-id-15160If you're in a notebook environment and type 361-4*-216 into a cell and get the answer then in the cell underneath you would refer to the previous calculation using the _ symbol. So typing sqrt(_) will give you the square root of the calculation in the previous cell. I find it's easiest to assign calculations to variables, eg a=361-4*-216, after which you can use the variable in other calculation easily.
![image description](/upfiles/13725567524007407.png)Sat, 29 Jun 2013 13:13:38 -0500http://ask.sagemath.org/question/10295/perform-arithmetic-on-previous-answerresult-without-copyingre-entering-it/?answer=15160#post-id-15160Comment by dazedANDconfused for <p>If you're in a notebook environment and type 361-4<em>-216 into a cell and get the answer then in the cell underneath you would refer to the previous calculation using the _ symbol. So typing sqrt(_) will give you the square root of the calculation in the previous cell. I find it's easiest to assign calculations to variables, eg a=361-4</em>-216, after which you can use the variable in other calculation easily.
<img alt="image description" src="/upfiles/13725567524007407.png"/></p>
http://ask.sagemath.org/question/10295/perform-arithmetic-on-previous-answerresult-without-copyingre-entering-it/?comment=17420#post-id-17420Yes. I attached a picture to my answer.Sat, 29 Jun 2013 15:47:08 -0500http://ask.sagemath.org/question/10295/perform-arithmetic-on-previous-answerresult-without-copyingre-entering-it/?comment=17420#post-id-17420Comment by bxdin for <p>If you're in a notebook environment and type 361-4<em>-216 into a cell and get the answer then in the cell underneath you would refer to the previous calculation using the _ symbol. So typing sqrt(_) will give you the square root of the calculation in the previous cell. I find it's easiest to assign calculations to variables, eg a=361-4</em>-216, after which you can use the variable in other calculation easily.
<img alt="image description" src="/upfiles/13725567524007407.png"/></p>
http://ask.sagemath.org/question/10295/perform-arithmetic-on-previous-answerresult-without-copyingre-entering-it/?comment=17421#post-id-17421The underscore symbol?
I tried that and got a TypeError message:
Traceback (click to the left of this block for traceback)
...
TypeErrorSat, 29 Jun 2013 14:24:51 -0500http://ask.sagemath.org/question/10295/perform-arithmetic-on-previous-answerresult-without-copyingre-entering-it/?comment=17421#post-id-17421Comment by Eviatar Bach for <p>If you're in a notebook environment and type 361-4<em>-216 into a cell and get the answer then in the cell underneath you would refer to the previous calculation using the _ symbol. So typing sqrt(_) will give you the square root of the calculation in the previous cell. I find it's easiest to assign calculations to variables, eg a=361-4</em>-216, after which you can use the variable in other calculation easily.
<img alt="image description" src="/upfiles/13725567524007407.png"/></p>
http://ask.sagemath.org/question/10295/perform-arithmetic-on-previous-answerresult-without-copyingre-entering-it/?comment=17419#post-id-17419This also works in the command-line version; the underscore holds the result of the last returned computation.Sat, 29 Jun 2013 20:54:01 -0500http://ask.sagemath.org/question/10295/perform-arithmetic-on-previous-answerresult-without-copyingre-entering-it/?comment=17419#post-id-17419