A small example package
Project description
Calculator_mgaidy
Overview
A basic calculator class that supports arithmetic operations and maintains a history log.
Installation
You can install the Calculator_mgaidy package using pip:
pip install calculator-mgaidy==0.0.7
Attributes
memory(float): The current memory value of the calculator.logs(List[str]): A list to store the history log of operations.precision(int): The precision to round results to.
Constants
MAX_NUMBER(float): The maximum allowed absolute value of number in calculations.MAX_POWER_LEVEL(int): The maximum allowed power level for exponentiation.MAX_PRECISION(int): The maximum allowed power level for exponentiation.
Methods
Each of the functions below have validations set in place to ensure that inputs and results are allowed values. Precision must be more than zero but less than 300. By default 10. Numbers maximum allowed absolute value is 1e300. (applies to input and output) Power and root inputs must be more than zero but less than 300.
set_precision(self, precision: int) -> None
Set the precision for rounding results.
reset_memory(self) -> float
Reset the calculator memory to zero and clear the history log.
print_history_logs(self) -> None
prints out log of operations since last reset.
add(self, number: float) -> float
Add a number to the calculator memory.
subtract(self, number: float) -> float
Subtract a number from the calculator memory.
multiply(self, number: float) -> float
Multiply the calculator memory by a number.
divide(self, number: float) -> float
Divide the calculator memory by a number.
power(self, number: float) -> float
Raise the calculator memory to the power of a given number.
root(self, number: float) -> float
Calculate the root of the calculator memory with a given exponent.
Usage Example
from calculator import Calculator
# Create a calculator instance
calc = Calculator()
# Perform operations
result = calc.add(5)
print(result) # Output: 5.0
result = calc.multiply(3)
print(result) # Output: 15.0
Development
For development, ensure that you have Python and pip installed. You can set up a virtual environment:
source venv/bin/activate # On Windows, use `venv\Scripts\activate`
Contributing
Feel free to contribute to this project by submitting bug reports, feature requests, or pull requests.
Testing
Run the tests to ensure everything is working as expected:
pytest
License
This project is licensed under the MIT License- see the LICENSE file for details.
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 calculator_mgaidy-0.0.7.tar.gz.
File metadata
- Download URL: calculator_mgaidy-0.0.7.tar.gz
- Upload date:
- Size: 5.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2e3e0c2815324f51abed4b69259580d92067946d5a688bd94a8c8e55ad612ac0
|
|
| MD5 |
c7a9670475ef9521a249c58dd45a6c97
|
|
| BLAKE2b-256 |
339ef73e2eddb2e6f68e020b2fcfef4c690a468b7a5dca6c9ac1178946b6d0f2
|
File details
Details for the file calculator_mgaidy-0.0.7-py3-none-any.whl.
File metadata
- Download URL: calculator_mgaidy-0.0.7-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2cdcd464e79016667f42c16fe3df7bfb08eeb327e0e8ecdef3ef49535052b14
|
|
| MD5 |
2f74698d1b6f7a6e7484f89a1b5a5389
|
|
| BLAKE2b-256 |
6188710f58994cfec405375abd12b30e35e6b74b7453fe6923281ee9b7f84e0b
|