Using Python as a Calculator
Doing math in python
A very Easy Language, yet can do it all.
Sometimes I'm building a web page, and I need to calculate some quick math. If I'm in a command line text editor, then I usually just open a new tab and type:
It's an easy parser to install, has very few dependencies, can run as a stand alone parser, or embed in web pages. It works on Linux (all variants,) Windows, Mac OSX, and PowerPC, Unix, FreeBSD, and just about any OS or machine I've ever tried. It's been used by everyone from command line scripting, to Video Games, Photo editors, and even NASA in it's shuttle control rooms. I use it for doing simple math.
In the photo here you can see how it is done. You can simply type 2+3 and it will output 5. Or you can if you want to write a program with math in it, type:
Get it? It can take a literal math problem, or a list of variables. Variable can be strings, (literal characters) or numbers and their actual values they represent. In the bottom of this hub, I'll put some links to help you all get started. Happy Hunting!
The Python Home Page
- Python Programming Language – Official Website
Home page for Python, an interpreted, interactive, object-oriented, extensible programming language. It provides an extraordinary combination of clarity and versatility, and is free and comprehensively ported.
The Python Wiki
- BeginnersGuide - PythonInfo Wiki
A wiki with much info to get you started. I refer to it whenever I get started on some new code.
More by this Author
An old traditional court of common law, though antiquated can still have modern uses. Is this dinosour still used? If so How? This is a brief look at one very complicated instrument of law revolving around the concept...
The full view of Hydrogen Good news is that it ships with many distributions like 64studio and Medibuntu. That means the live cd will run it, and you won't have to go through installing a new operating system just to...
In my research for common law remedies of which I wrote a hub about, I've come across a movement known as the Freeman-on-the-land. I hadn't heard the term in over a decade. It has been since I knew a fellow who had...