A simple calcaultor for daily usage
Project description
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.
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file dailycalc-2024.0.1.1.tar.gz.
File metadata
- Download URL: dailycalc-2024.0.1.1.tar.gz
- Upload date:
- Size: 175.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6043494cd276415af7e4cc314d738e81b0aca317a792c16e8b2c1cf759a14eec
|
|
| MD5 |
532c2415e820e652de393fbc3c2dc98e
|
|
| BLAKE2b-256 |
21d4377e5b00f95d533a61778cbbd4694f9299b804405933d5e9020708239bf4
|
File details
Details for the file dailycalc-2024.0.1.1-py3-none-any.whl.
File metadata
- Download URL: dailycalc-2024.0.1.1-py3-none-any.whl
- Upload date:
- Size: 21.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f3ccff22bf5da27d968324717cf2ebae44eecc464ef25b89ea974a9d9767f1d
|
|
| MD5 |
cf9612f5c6525d05897cec944d78f79c
|
|
| BLAKE2b-256 |
d9579bfe73531d2725b055491d734cede7d24920496c6cceb08854288a576cbc
|