A python calculator library.
Project description
Calculator-LIB
A Python calculator library providing stateless arithmetic, power/root, modulo, rounding, and logarithmic/exponential operations.
- Distribution name:
calculator-lib - Python package:
calculator_lib(imported asfrom calculator_lib import Calculator) - Repository: rubensgomes/calculator-lib
Requirements
- Python 3.14+
- Poetry
Getting Started
# Install dependencies
poetry install
# Activate environment
poetry env activate
Usage
from calculator_lib import Calculator
calc = Calculator()
calc.add(2, 3) # 5
calc.subtract(10, 4) # 6
calc.multiply(3, 4) # 12
calc.divide(10, 2) # 5.0
calc.power(2, 3) # 8
calc.sqrt(16) # 4.0
calc.nth_root(27, 3) # 3.0
calc.modulo(10, 3) # 1
calc.floor_divide(7, 2) # 3
calc.absolute(-5) # 5
calc.round_number(3.14159, 2) # 3.14
calc.floor(3.7) # 3.0
calc.ceil(3.2) # 4.0
calc.log10(100) # 2.0
calc.ln(math.e) # 1.0
calc.exp(1) # 2.718281828459045
Invalid inputs raise ValueError:
calc.divide(10, 0) # ValueError: Cannot divide by zero
calc.sqrt(-1) # ValueError: Cannot take square root of a negative number
calc.log10(0) # ValueError: Cannot take logarithm of a non-positive number
Common Poetry Commands
-
The following commands are used during development:
# Update the dependencies fournd in `pyproject.toml` poetry update --verbose # Installs the project dependencies poetry install --verbose # Activates Poetry-managed virtual environment in your current shell eval "$(poetry env activate)" # Runs static type checker on Python `src/` folder poetry run mypy src/ # Sorts and groups import statements poetry run isort src/ tests/ # Formats your Python code poetry run black src/ tests/ # Linting poetry run pylint src/ # Run PyTest on the code poetry run pytest # Run tests with coverage poetry run pytest --cov
License
Project details
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 calculator_lib_rubens-0.1.1.tar.gz.
File metadata
- Download URL: calculator_lib_rubens-0.1.1.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.6.87.2-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7d3426b0ce06d5b03547dfa92765ab7dbe712b3aa724c98b56f4a39d0f5a4d79
|
|
| MD5 |
82d1d1e3c273ed93c8e34115c287ea4b
|
|
| BLAKE2b-256 |
92785ce5542bfc8eb3d487f52b082baaa2ea1d3a2f3fed3639b64308c48495f8
|
File details
Details for the file calculator_lib_rubens-0.1.1-py3-none-any.whl.
File metadata
- Download URL: calculator_lib_rubens-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/2.2.1 CPython/3.12.3 Linux/6.6.87.2-microsoft-standard-WSL2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
85f8ba4c3daf8b2f6a6d79b2cc3b203ff6e025ac9609da14c83c1eaa56e5a8e4
|
|
| MD5 |
593569bbbbf751c5a8369aa771ecf8f5
|
|
| BLAKE2b-256 |
2fbab8005c087594588ac93fef71e531a03bceb6f232af00e5a3bf895a7074fa
|