Once I was looking for “expression calculator”. The expression calculator is different from normal calculator like calc.exe, which cannot use variable freely as algebra. But the expression calculator, we can predefine a variable with a value, then evaluate the variables in algebraic expression. It is very useful. My favourite expression calculator is SpeedCrunch.

Then, recently, I want to test a math function in SpeedCrunch, but this is impossible, since expression calculator can only define the variable, but not define a function. I remembered the title of Python Tutorial, “Using Python as a Calculator“. Yes, expression calculator, with ability to define function, then Python will be the one.

So, I tried Python, writing the function in the interactive console, easy as it is. Not only that, one can do the fractions and also calculating the date time using Python. So, Python is now my #1 expression calculator. The only drawback I found is that Python does not have the mathematic constants as SpeedCrunch. That means, one needs to find the constants, and also the the unit conversion by our own.

Besides that, to use math functions such as logarithm and trigonometry functions, one must import the math module.

from math import *
from fractions import Fraction #to use the fraction
from datetime import *

### Like this:

Like Loading...

*Related*

Python is my favourite calculator too. A very useful feature of the interactive shell is that it saves the value of the last expression in the special variable “_” (underscore). Ex.: 2 + 3 will print 5. Then you can write _ * 3, which is 15, etc.

Good, I didn’t know the “_” variable before. Thanks for your sharing.