A small calculator module for Python
Project description
Calculator Module for Python
By White Night
Install
# Linux/macOS
python3 -m pip install -U whiteCalculator
# Windows
py -3 -m pip install -U whiteCalculator
QuickStart
Calculator
from whiteCalculator import Calculator
c = Calculator()
print(c.run("1+8(5^2)"))
# Output: 201
print(c.run("9Ans"))
# Output: 1809
Formula
from whiteCalculator import Formula
Formula.PythagorasTheorem.getA(b=4, c=5)
# Output: 3
Formula.PythagorasTheorem.getA(b="2^2", c="√(25)")
# Output: 3
Formula List
PythagorasTheorem, LensFormula, LinearMagnificationFormula
TODO
- make Doc
- more Formula
- Calculate without eval
Errors
from whiteCalculator import Calculator
c1 = Calculator(skipError=True) # Default is True
c1.run("9/0")
# Output: Error: division by zero
c2 = Calculator(skipError=False)
c2.run("9/0")
# Outputs:
# Traceback (most recent call last):
# ...
# ZeroDivisionError: division by zero
You can use:
sin
/asin
/sinh
cos
/acos
/cosh
tan
/atan
/tanh
ln
/log
×
/•
^
/*
/power
√
/sqrt
π
/pi
%
÷
Ans
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
whiteCalculator-0.0.6.tar.gz
(7.1 kB
view hashes)
Built Distribution
Close
Hashes for whiteCalculator-0.0.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3326b3a06e2cb58a17798dcb97e8eabafd11821c57d5ae0ee8e32c836e4ac17 |
|
MD5 | 04d015cc01d9aa63b2e10b2de3033a03 |
|
BLAKE2b-256 | 6a9854752c5278ec3e27d8d5b323d1003f749aa62941cc98ea03fce36995cc49 |