Metadata-Version: 2.4
Name: scientific-calculator-v1
Version: 0.3.1
Summary: Scientific calculator for Python and the terminal: trig, logs, roots, factorials and safe expression evaluation.
Author-email: Sarif Mia <sarifmia.ofc@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/sarif-mia/scientific-calculator
Project-URL: Documentation, https://github.com/sarif-mia/scientific-calculator#readme
Project-URL: Source, https://github.com/sarif-mia/scientific-calculator
Project-URL: Tracker, https://github.com/sarif-mia/scientific-calculator/issues
Keywords: calculator,math,scientific,cli
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Provides-Extra: test
Requires-Dist: pytest>=7; extra == "test"
Dynamic: license-file

# 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+.

```sh
pip install scientific-calculator-v1
```

## Command line

```console
$ 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

```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 as `sin(180) == 0.0`; type hints; CI.
- **0.2.1**: first PyPI release; `scientific-calculator` command.

## License

MIT License. See [LICENSE](LICENSE).
