A customizable Python calculator with user-defined operators and constants.
Project description
CustomCalc A small, customizable calculator for Python that lets you define your own operators, constants, and functions. Uses NumPy for math operations.
Install: pip install customcalc
Example:
from customcalc import build_basic_calc
# default operators/expressions
calc = build_basic_calc()
print(calc.calculate("1 + 2 * 3")) # 7
print(calc.calculate("cos(pi / 3)")) # 0.5
print(calc.calculate("3! + 4")) # 10
# Custom operator example:
from customcalc import CalculatorBuilder
import numpy as np
b = CalculatorBuilder()
b.addBinaryOperator("plus", 0, np.add)
b.addConstant("one", 1)
b.addConstant("two", 2)
calc = b.build()
print(calc.calculate("one plus two")) # equals three
License: MIT
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
customcalc-0.1.0.tar.gz
(8.2 kB
view details)
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 customcalc-0.1.0.tar.gz.
File metadata
- Download URL: customcalc-0.1.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2430cdc511e9f003d6271591018e55fd23e99a69f16b7445c091b2f3eed27b7
|
|
| MD5 |
2108f1681afef0afbf60659685d6f94f
|
|
| BLAKE2b-256 |
125ce076a56ca8453845428d41e3ef0e16cc444c96eb8892146ee6ae5282df29
|
File details
Details for the file customcalc-0.1.0-py3-none-any.whl.
File metadata
- Download URL: customcalc-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d098b6f3960bc08f6c02170bd7428534550dfd7b0754b6fc214284f14b9b5a9f
|
|
| MD5 |
a03ba1dd3456c47bfb7e868131ac8137
|
|
| BLAKE2b-256 |
2d4bd30799656cd175de602e8fa595a8f56bac12e56bf3042437c5c92a65b9c2
|