Package: cli-calc
cli-calcPowerful yet easy command line calculator.IntroductionPlease note: Using plain python at the command line already does provide a pretty decent calculator:$ python
Python 3.8.5 (default, Aug  2 2020, 16:00:15)
[Clang 11.0.0 (clang-1100.0.33.17)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> 2**10
1024
>>> _ / 10
102.4
>>> import math
>>> math.pi
3.141592653589793
>>> math.sin(math.pi / 2)
1.0
>>> exit()[
Read more aboutPython as a Calculator.
]But not all is straight forward.
For example, if you want to calculatesin(pi/2):First you need toimport math,and then use it withmath.sin( math.pi / 2 ).Butthere must be a better way!And there is...cli-calc$ cli-calc
hex, int, float, : INPUT
0x0, 0, 0.0, : 2**10
2**10
0x400, 1024, 1024.0, : _ / 10
1024.0/10
0x66, 102, 102.4, : pi
pi
0x3, 3, 3.141592653589793, : sin(pi / 2)
sin(pi/2)
0x1, 1, 1.0, : q
$Batteries included:cli-calcadds the standardmathlibrary to the mix, as well as cmath and others.Provides convenience functions for formatted output, likefractionsandIEEE 754.Supports line input from files and Unix pipes.And some more... :-)More examples$ cli-calc
hex, int, float, : INPUT
0x0, 0, 0.0, : cos(pi/2)
cos(pi/2)
0x0, 0, 6.123233995736766e-17, : 0xFF ^ 0b10
0xFF^0b10
0xfd, 253, 253.0, : 2**8-1
2**8-1
0xff, 255, 255.0, : log(e)
log(e)
0x1, 1, 1.0, : comb(49,6)
comb(49,6)
0xd56048, 13983816, 13983816.0, : factorial(42)
factorial(42)
0x3c1581d491b28f523c23abdf35b689c908000000000, 1405006117752879898543142606244511569936384000000000, 1.40500611775288e+51, : random()
random()
0x0, 0, 0.24958817003921918, : cmath.phase(complex(-1.0, 0.0))
cmath.phase(complex(-1.0,0.0))
0x3, 3, 3.141592653589793, : q
$Included Math LibrariesReady to use out of the box:standard operators-, >>, ...standard math librarycd, log, sin, sinh, gamma, pi, e, tau, inf, nan...cmathphase(complex(-1.0, 0.0)), and then most of the above with complex numbers.randomrandom, choice(['win', 'lose', 'draw']), mean, ...built in functionsmax, help, sum, ...Installationpipinstallcli-calcpypi cli-calcConfigurationFor convenience, add a shell script in~/bin:cd~/bin
vicli-calcwith the following lines:Note: Please adjust the path!path=~/path/to/your/cli-calc/cd$pathpython3-mcli_calcMake it executable:chmoda+xcli-calcthen use it anywhere. :-)echo"7+8"|cli-calc
catfoo.bar|cli-calc
cli-calcHelpcli-calc
h
--------------------------------------------------cli-calc0.3.1:Powerfulyeteasycommandlinecalculator.INPUT:"q"forquit,"h"forhelp"_"forlastfloatvalue"_int_"forlastintvalue"sin(pi/2)"forsinus,..."pi","tau"and"e"forpi,tauandEuler"+f"toadddisplayforfraction,"-f"tosuppressdisplayforfractionOtherlettersare:he(x),(o)ctal,(b)inary,(i)nteger,(f)raction,(t)ruth,i(e)ee,ieee_bi(n),f(r)om_ieee"float"isalwaysvisibleAlsotry"cos(pi/2)","0xFF ^ 0b10","2**8-1","factorial(42)","help(math)"Seehttps://docs.python.org/3/library/math.html,usewithout"math."https://www.w3schools.com/python/python_operators.asphttps://github.com/cruisen/cli-calc(c)2022-2022NikolaivonKrusenstiern,License:MIT--------------------------------------------------
hex,int,float,:INPUTPermalink to this document as agithub pageWarningUse ofevalis evil.
However precautions are taken.Pull RequestPR's are Welcome!Please read more aboutContributingand ourdevelopmentenvironment and tool set.Or just simply raise anissue.LicenseMITCreditsThis project was generated withwemake-python-package. Current template version is:d06993f12e3ffad79652a2aec86189dee92d94dd. See what isupdatedsince then.