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.4
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 number in calculations.MIN_NUMBER(float): The minimum allowed number in calculations.MAX_POWER_LEVEL(int): The maximum allowed power level for exponentiation.
Methods
__init__(self, memory: float = 0, precision: int = 10) -> None
Initialize the Calculator.
set_precision(self, precision: int) -> None
Set the precision for rounding results.
history_log(self, symbol: str, number: float) -> List[str]
Log an arithmetic operation to the history log.
clear_history_log(self) -> None
Clear the history log.
reset_memory(self) -> float
Reset the calculator memory to zero and clear the history log.
input_number_validation(self, number: float) -> float
Validate if the provided number is within the allowed range.
input_power_validation(self, power: float) -> float
Validate if the provided power is within the allowed range.
result_validation(self, result: float) -> float
Validate if the result is within the allowed range.
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
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.4.tar.gz.
File metadata
- Download URL: calculator_mgaidy-0.0.4.tar.gz
- Upload date:
- Size: 5.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
28a01c7f50a96a904fad923108ce88840d49361eedaf2c2f43fb54c363e0de7c
|
|
| MD5 |
7f3943bb7868608c18c9fadfbe631a15
|
|
| BLAKE2b-256 |
df84283f701ee5ba4c383351070c12ea578d345021a7e90aa5ed5034980bf8a4
|
File details
Details for the file calculator_mgaidy-0.0.4-py3-none-any.whl.
File metadata
- Download URL: calculator_mgaidy-0.0.4-py3-none-any.whl
- Upload date:
- Size: 4.8 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 |
fc6201c918f4b48c9c01ba2c3162842709ac3809fb2aed1fabe1ee88a3b0472d
|
|
| MD5 |
e976775b37771211c06b191a57715288
|
|
| BLAKE2b-256 |
538a1a8e6026bc4afd2cb802edec36c8fb1a7d80ddcf4c8c02dc7a29421e9026
|