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.