DailyCalc - A Simple Calculator
python>=3.11
dependency : colorama (not mandatory, if you don't need highlight, you can uninstall it later)
Description
A simple calculator based on decimal.Decimal.
Decimal “is based on a floating-point model which was designed with people in mind, and necessarily has a paramount guiding principle – computers must provide an arithmetic that works in the same way as the arithmetic that people learn at school.” – excerpt from the decimal arithmetic specification
Output is rounded with maximum 10 decimal place for Infinitesimal decimals.
sqrt(2) => 1.4142135624 # keep 10 decimal places
0.1 + 0.2 => 0.3
ln(exp(10)) => 10.0000000000 # inevitable loss of precision
Usage
install by pip
pip install dailycalc
import into your code
from dailycalc import calculate, check_calc
if check_calc("sum(123, 3)"):
print(calculate("sum(123, 3)"))
# or
try:
print(calculate("sum(123, 3)"))
except ValueError as e:
print(e)
once-off calculate
python -m dailycalc "sum(0.1, 0.2)"
iteractive mode
python -m dailycalc -i
# or
idailycalc
Operators & Functions
supporting:
+ - \* / ^
sum max min abs round hex oct sqrt log ln exp
Interactive mode
Every result is stored in register from [a-z] cyclically, that is when reaching the last one "z", the register would go back to "a" and cover the old value.
"@a" gives the value in "a". "@@" gives the previous result.'
for example:
Support HEX, OCT, Scientific input
HEX:0x12E,0X12Eonly support integarOCT:0o123,0O123only support integar- Scientific Notation:
-123.12E-123or-123.12e+123
Error message with highlight
Reference for interactive mode
--- Modes ---
STAY mode (prompt "===") (Default) save result by call "save" command
WALKING mode (prompt ">>>") automatically save results and move to next register
--- Commands ---
"exit" exit program.
"show" show all results in register.
"reset" clear all results in register.
"stay" switch to STAY mode.
"go" save result & switch to WALKING mode.
"save [tag]" save result (in STAY Mode).
--- Functions ---
sum(1, 2, 2+1) => 6
max(1, sum(2, 1)) => 3
min(1, 2) => 1
abs(1-12) => 11
round(12.16, 1) => 12.2
hex(10) => 0xa
oct(10) => 0o12
sqrt(1.44) => 1.2
ln(exp(100)) => 10.0000000000
log(100) => 2
Future Plans
add more function & operator, bugfix.
Release files for dailycalc 2024.0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| dailycalc-2024.0.1.1.tar.gz | 175.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| dailycalc-2024.0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size:196.9 kB
Release files / dailycalc-2024.0.1.1.tar.gz
| Download URL | dailycalc-2024.0.1.1.tar.gz |
|---|---|
| Size | 175.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6043494cd276415af7e4cc314d738e81b0aca317a792c16e8b2c1cf759a14eec
|
|
BLAKE2b-256 checksum How to use checksums |
21d4377e5b00f95d533a61778cbbd4694f9299b804405933d5e9020708239bf4
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.7
|
Release files / dailycalc-2024.0.1.1-py3-none-any.whl
| Download URL | dailycalc-2024.0.1.1-py3-none-any.whl |
|---|---|
| Size | 21.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
0f3ccff22bf5da27d968324717cf2ebae44eecc464ef25b89ea974a9d9767f1d
|
|
BLAKE2b-256 checksum How to use checksums |
d9579bfe73531d2725b055491d734cede7d24920496c6cceb08854288a576cbc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.11.7
|