Scientific Calculator
A scientific calculator for Python and the terminal. It handles arithmetic, trigonometry in degrees or radians, logarithms, roots and factorials, and it evaluates expressions safely without using eval.
No dependencies. Python 3.9+.
pip install scientific-calculator-v1
Command line
$ scientific-calculator add 2 3
Result: 5.0
$ scientific-calculator "2*sin(30) + sqrt(16) + 3!"
Result: 11.0
$ scientific-calculator --rad "cos(pi)"
Result: -1.0
$ scientific-calculator # interactive mode
>>> 2^10
1024
>>> ans / 4
256.0
>>> quit
Interactive mode understands help, deg, rad, ans (the last result) and quit.
You can also run it as a module: python -m scientific_calculator.cli add 2 3.
Operations
| Operation | Meaning |
|---|---|
add a b, subtract a b, multiply a b, divide a b |
Basic arithmetic |
mod a b |
Remainder |
percent value pct |
pct% of value |
power base exp, sqrt x, cbrt x, root x n |
Powers and roots |
exp x, ln x, log x [base] |
Exponential and logarithms (base 10 by default) |
sin x, cos x, tan x, asin x, acos x, atan x |
Trigonometry (degrees unless --rad is given) |
factorial n, abs x |
Factorial and absolute value |
Expressions support + - * / // % **, with ^ meaning power. They also support parentheses, postfix !, the constants pi, e and tau, and all the functions above.
Python
from scientific_calculator import ScientificCalculator, evaluate
calc = ScientificCalculator() # degrees
calc.sin(30) # 0.5
calc.log(8, 2) # 3.0
calc.factorial(5) # 120
calc.evaluate("2 * sin(30) + sqrt(16)") # 5.0
ScientificCalculator(angle_unit="rad").sin(3.14159 / 2) # ≈ 1.0
evaluate("(2 + 1)! ^ 2") # 36
Invalid input such as sqrt(-1), 1/0 or an unknown function raises ValueError with a clear message.
Changelog
- 0.3.1: expression evaluation, interactive mode, radians mode,
asin/acos/atan,ln,cbrt,root,factorial,mod,percent,abs; clean results such assin(180) == 0.0; type hints; CI. - 0.2.1: first PyPI release;
scientific-calculatorcommand.
License
MIT License. See LICENSE.
Metadata
Release files for scientific-calculator-v1 0.3.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 | Provenance | Actions |
|---|---|---|---|---|
| scientific_calculator_v1-0.3.1.tar.gz | 10.3 kB | Without provenance | Details for scientific_calculator_v1-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| scientific_calculator_v1-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for scientific_calculator_v1-0.3.1-py3-none-any.whl |
Total release size: 19.9 kB
Release files / scientific_calculator_v1-0.3.1.tar.gz
| Download URL | scientific_calculator_v1-0.3.1.tar.gz |
|---|---|
| Size | 10.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c5283051051318294ae4ddb1cf984d86e89a5cfd49de40e22b5736932392b2b0
|
|
BLAKE2b-256 checksum How to use checksums |
7481c9fe7929ecd7194b21643fc7a7404c00de8c579cd20c911aef2f9391d946
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / scientific_calculator_v1-0.3.1-py3-none-any.whl
| Download URL | scientific_calculator_v1-0.3.1-py3-none-any.whl |
|---|---|
| Size | 9.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
78ddc5744887dd56c687a8a6e1420c274863aa0f0524f43e86f748f9dcf8707b
|
|
BLAKE2b-256 checksum How to use checksums |
63b7015896fa0f5eedb4c63eedc35f2dbee3cf12aae421a3bd461b532f3e4340
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for scientific-calculator-v1 0.3.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.