Last Updated 04/18/2017

Sage Essentials
Section 1: Numerical Calculations

Clearing Variables

Example 2 Clearing one variables at a time: the reset() command

Sometimes you will want to "clear" a variable in memory so that you can use it in a new situation.

Here is an example. First we assign x the value 1.

Now assume that we start a new problem and want to enter the general algebraic expression x2+x +1 and assign it the name w. If we just enter this, Sage automatically substitutes the previous value for x.

In order to get x to be a general variable again we must first "clear" (i.e. erase from Sage's memory) our earlier value for x. This is accomplished by using reset() command. Note that we use single quotes here.


← Previous Example Next Example →