This Module implements a simple calculator interface with in instance memory,
Project description
Calculator Package
The Calculator package provides a simple Python class, Calculator, that can perform basic arithmetic operations and manipulate a memory value.
Installation
You can install the Calculator package using pip. Open your terminal and run:
pip install fkriza-calculator
Usage
Once installed, you can use the Calculator class in your Python code as follows:
from calculator import Calculator
# Create a Calculator instance
calculator = Calculator()
# Perform arithmetic operations
result = calculator.add(5) # Add 5 to the memory
print(result) # Output: 5
result = calculator.subtract(3) # Subtract 3 from the memory
print(result) # Output: 2
result = calculator.multiply(4) # Multiply the memory by 4
print(result) # Output: 8
result = calculator.divide(2) # Divide the memory by 2
print(result) # Output: 4.0
result = calculator.nth_root(2) # Take the square root of the memory
print(result) # Output: 2.0
# Reset the memory to 0
calculator.reset()
print(calculator.memory) # Output: 0.0
Error Handling
- Division by zero will raise a
ValueError. - Taking an even root of a negative number will raise a
ValueError.
Memory Management
The Calculator class maintains its own memory, starting at 0. Each operation updates the memory value and returns it.
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 fkriza-calculator-1.0.1.tar.gz.
File metadata
- Download URL: fkriza-calculator-1.0.1.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e19ce5010e38c8c32832d453895c508568a429fe7afd6b90a5253c6889ea62ad
|
|
| MD5 |
9a278aac93ce0671c88f01cc38a6e95e
|
|
| BLAKE2b-256 |
9c89c277958e93df67cd225574dd591b68cfd2bba82dca69c2305cc6cb317ab8
|
File details
Details for the file fkriza_calculator-1.0.1-py3-none-any.whl.
File metadata
- Download URL: fkriza_calculator-1.0.1-py3-none-any.whl
- Upload date:
- Size: 2.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e731d119c57afb31cca85ac2429d3378f82a79573ca91ef3159c58668a458821
|
|
| MD5 |
77cb7bddcbd107354e51132be43df0ef
|
|
| BLAKE2b-256 |
4c14a5cd426a40a6524a0b698095a55ed66cf7c18dbc192e48eac0e07021329c
|